Using sizeof() on malloc'd memory [duplicate]
Possible Duplicate: newbie questions about malloc and sizeof I am trying to read strings into a program. When I noticed that the strings were sometimes being corrupted, I tried the following code: void *mallocated = malloc(100); printf("sizeof(mallocated) = %d\n", sizeof(mallocated)); According to my program, the size of mallocated was 8 , even though I allocated 100 bytes for it. Because of this, whenever I try to store a string longer than 8 bytes, everything after the 8th byte will sometimes disappear. Why is this happening, and how can I prevent it? Because the size of the "string" pointer