Use %p everywhere with printf() #9
@ -28,7 +28,7 @@ int main()
|
|||||||
{
|
{
|
||||||
char* variable = malloc(200);
|
char* variable = malloc(200);
|
||||||
*variable = 3;
|
*variable = 3;
|
||||||
printf("Allocated variable at address %lx\n", (unsigned long int)variable);
|
printf("Allocated variable at address %p\n", variable);
|
||||||
free(variable);
|
free(variable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ int main()
|
|||||||
sleep(1);
|
sleep(1);
|
||||||
void* allocated = malloc(CHUNK);
|
void* allocated = malloc(CHUNK);
|
||||||
do {
|
do {
|
||||||
printf("Allocating 4 MB of memory... %lx\n", (unsigned long)allocated);
|
printf("Allocating 4 MB of memory... %p\n", allocated);
|
||||||
sleep(1);
|
sleep(1);
|
||||||
} while ((allocated = malloc(CHUNK)));
|
} while ((allocated = malloc(CHUNK)));
|
||||||
perror("malloc");
|
perror("malloc");
|
||||||
|
Loading…
Reference in New Issue
Block a user