-3

What is the size of pointers in c++?

char a;
char *b=a;
cout<<sizeof(b);

Output is 2 I don't know why.

cout<<sizeof(const);    //o/p is 2
 cout<<sizeof(NULL);   //o/p is 2

1 Answers1

2

The size of a pointer in c++ depends on the system you are compiling for and the compiler you are using.

In general, if you are on a 32 bit system the pointer will have a size of 4 bytes. On a 64 bit system it'll be 8 bytes and so on, but that is not guaranteed.

Just use sizeof(char*) and you should get the answer.

jule
  • 96
  • 3