Use %p everywhere with printf() #9

Merged
apio merged 6 commits from printf_pointers into main 2022-10-08 16:27:37 +00:00
2 changed files with 2 additions and 2 deletions
Showing only changes of commit 40099feb80 - Show all commits

View File

@ -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);
} }

View File

@ -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");