Why doesn't sizeof tell me the size of the block of memory pointed to by a pointer?

Q

Why doesn't sizeof tell me the size of the block of memory pointed to by a pointer?

✍: Guest

A

sizeof tells you the size of the pointer. There is no portable way to find out the size of a malloc'ed block. (Remember, too, that sizeof operates at compile time

2016-03-21, 1193👍, 0💬