What is size of pointer variable?
The size of pointer depends of the machine you are working on.
On 16-bit machine size of pointer is 16 bits, on 32-bit machine size of pointer is 32 bits (4 bytes), while on 64 bit machine is 64 bits (8 byte).
Regardless of what data type they are pointing to, they have fixed size.
Example on 64 bit machine
main()
{
char *a;
int *b;
float *c;
void *d;
printf("%d %d %d %d",sizeof(a),sizeof(b),sizeof(c),sizeof(d));
}
Output
8 8 8 8
On 16-bit machine size of pointer is 16 bits, on 32-bit machine size of pointer is 32 bits (4 bytes), while on 64 bit machine is 64 bits (8 byte).
Regardless of what data type they are pointing to, they have fixed size.
Example on 64 bit machine
main()
{
char *a;
int *b;
float *c;
void *d;
printf("%d %d %d %d",sizeof(a),sizeof(b),sizeof(c),sizeof(d));
}
Output
8 8 8 8
Comments
Post a Comment