3 votes 3 votes #include<stdio.h> int main() { int a = 10; void *ptr = &a; printf("%d", sizeof(ptr)); return 0; } output =8 how ?if we know size of pointer is already machine dependent then in this case ptr is referring a address of int then how output 8 ? Programming in C programming-in-c pointers + – set2018 asked Aug 10, 2017 set2018 1.6k views answer comment Share Follow See all 2 Comments See all 2 2 Comments reply prateekdwv commented Aug 10, 2017 reply Follow Share Sizeof is an operator which returns the amount of memory reserved for storing the value of a certain Data Type or a Variable. Since a pointer (to any data type) ultimately stores an address of some memory location, it reserves sufficiently many bytes that are required to address a location in memory. In 64-bit machines, memory is addressed using 64 bits i.e., 8 Bytes. Now if I had to store an address of a location in memory at some other location in memory, I will need 8 Bytes of space. This is what the sizeof is returning. 2 votes 2 votes prateekdwv commented Aug 10, 2017 reply Follow Share In case you are wondering what difference does void data type make to the pointer, take this example #include<stdio.h> void main() { int a = 10; void *ptr = &a; char *ptr2 = (char *)ptr + 1; int *ptr3 = (int *)ptr + 1; printf("%p %p %p\n", ptr, ptr2, ptr3); } Casting void pointer to an int or any other data structure doesn't change the storage capacity of a pointer. However, when the void pointer is cast to an int, it will fetch data from two subsequent memory location (going by convention, though this is machine dependent) when dereferencing the pointer. 0 votes 0 votes Please log in or register to add a comment.