Between the int pointer and long double pointer which pointer will consume more memory space?

Answer: 
Size of any type of pointer is independent of the data type which is it is pointing i.e. size of pointer is always fixed.  Size of any type (near) of pointer in c is two byte.  For example:

#include<stdio.h>
void main(){
    int *p1;
    long double *p2;
    printf("%d   %d",sizeof(p1),sizeof(p2));
}


Output: 2   2
Since both pointers int and long double are pointing to only first byte of int data and long double data respectively.



Hence both int pointer and long double pointer stores only address in 16 bits. Thus both of them will occupy exactly equal memory space. 

1 comment:

MOHIT KHATTER said...

nice tute...........