C size of void pointer



What is the size of Void Pointer variable in C ?


Pointer  : 
Pointer is the variable that stores the address of another variable .

How to calculate size of Pointer ? 

  1. Size of Void Pointer can be evaluated by using sizeof operator
  2. Pointer stores the address of the Variable .
  3. Address of variable is nothing but the integer value .
  4. In C , for storing integer value 2 bytes are required .
  5. So void  Pointer variable requires 2 bytes of memory.


int main(void)
{
int num = 0;

void *ptr;

num = 15;

ptr = #

/* Output the size */

printf("Size of Pointer : %d Bytes",sizeof(pointer));

return 0;
}


Output :
 Size of Pointer : 2 Bytes

Bookmark & Share