0
Size of variable
Int var=5532; Int*varsize=var; Cout<< //i want to print pointers size in bytes?
3 Antworten
+ 1
int var = 5532;
int *varsize = &var;
std::cout << sizeof(varsize);
Regardless of the data type they are pointing to, pointers have fixed size and is related to the architecture. On 32-bit machine the size of a pointer is 32bits (4 bytes), while on 64 bit machine it is 8 bytes.
0
And what if i want to print size of var
0
int var = 5532;
int *varPtr = &var;
cout<<sizeof(var)<<endl; //without using a pointer
cout<<sizeof(*varPtr)<<endl; //using a pointer