Why is the size of “a” coming out to be 8 bytes? Shouldn’t it be 4 bytes since it is an integer pointer?
Doubt regarding sizes in memory allocation
hello @Lakshita2002
size of any datatype is not fixed , it depends on various factors like computer artitecture , compiler etc.
for integer 4byte is common
1 Like
Ok, please correct me if I am wrong
The size of an integer variable can be either 4 bytes or 8 bytes, depending on the factors you mentioned. The same applies for integer pointer variables as well. Right?
And there’s no compulsion that integer and integer pointer variables should have the same size (4 bytes and 4 bytes or 8 bytes and 8 bytes)…?
pointer size is always independent from its datatype.
1 Like
Ok, I get it now
Size of datatypes depends on a lot of factors and the size of pointers and its datatype is independent.
Thank you!