Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <malloc.h>
- int *intPointer;
- int main()
- {
- char nameVar[30];
- short exampleVar;
- short shortVar1;
- short shortVar2;
- int intVar1;
- int intVar2;
- int intVar3;
- char *charPointer;
- float floatVar1;
- float floatVar2;
- exampleVar = 99;
- shortVar1 = 12;
- shortVar2 = 24;
- intVar1 = 16;
- intVar2 = 78;
- intVar3 = 10;
- floatVar1 = 6;
- floatVar2 = 3;
- charPointer = (char *)malloc(2000);
- intPointer = (int *)malloc(1000);
- strcpy(charPointer, "David Barnes");
- // Example: Below statement illustrates how to display address of the variable exampleVar
- printf("\n The address of variable exampleVar is : %p", &exampleVar);
- // DONE – Please uncomment and complete each statement below to print the
- // DONE memory location allocated to the respective variable
- printf("\n The address of variable shortVar1 is : %p", &shortVar1);
- printf("\n The address of variable shortVar2 is : %p", &shortVar2);
- printf("\n The address of variable charPointer is : %p", &charPointer);
- printf("\n The memory allocated for charPointer is : %d bytes.", _msize(charPointer));
- printf("\n The address of variable nameVar is : %p", (void *)&nameVar);
- printf("\n The address of variable intVar1 is : %p", &intVar1);
- printf("\n The address of variable intVar2 is : %p", &intVar2);
- printf("\n The address of variable intVar3 is : %p", &intVar3);
- printf("\n The address of variable intPointer is : %p", &intPointer);
- printf("\n The memory allocated for intPointer is : %d bytes.", _msize(intPointer));
- printf("\n The address of variable floatVar1 is : %p", &floatVar1);
- printf("\n The address of variable floatVar2 is : %p", &floatVar2);
- //DONE - Add proper lines of code to print the location and the amount of memory
- //allocated to dynamic variables (pointers)
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement