example code for finding size of a pointer in c:
What is the output of below C program.
int *p = malloc(sizeof(int) * 5);
printf("%d",sizeof(p)); //assume int size is 4 bytes in this system.
it prints 4. It doesn't matter how many bytes you have allocated using this pointer. when you use sizeof operator on any pointer, it always returns 4(if int size is 4bytes).
Back To Top