0

Size of a pointer

It doesn't matter that for which datatype the pointer is initialised it will always hold an integer value hence it's size will always be 4 https://code.sololearn.com/cLEZ8RI9B2YD/?ref=app

12th Aug 2017, 8:02 PM
AMIT KUMAR
AMIT KUMAR - avatar
4 odpowiedzi
+ 6
It won't always be 4, it depends on the architecture. Ex. pointers on 64 bit systems are 8 bytes
12th Aug 2017, 8:07 PM
aklex
aklex - avatar
+ 4
@AMIT KUMAR It still won't always be the same size as a regular int ;). Depending on the compiler, pointers could be 8 bytes while integers could be only 4 bytes. Compilers may do that for a couple reasons like: 1) backwards compatibility 2) you can store two 32 bit integers in one 64 bit register 3) reducing memory consumption
12th Aug 2017, 9:38 PM
aklex
aklex - avatar
0
I agree with your point @aklex , it will always be equal to the size of an int that vary acc. to the arch.
12th Aug 2017, 8:18 PM
AMIT KUMAR
AMIT KUMAR - avatar
0
I didn't know that thanks @aklex
13th Aug 2017, 2:39 AM
AMIT KUMAR
AMIT KUMAR - avatar