C %p printing 16 instead of 8 bytes

Viewed 286

I need to print the address of a pointer. This is my code:

float arr[5] = {1.2 , 2.3 , 5 , 7.1 , 9.6};
float *ptrarr;
ptrarr = &arr[0];

printf("Address of ptrarr+2=%p,%p \n\n",ptrarr+2,&arr[2]);

I knew that pointer addresses have 8 bytes, but my output is always 16 bytes. This is the output

Address od ptarr+2=000000000061FDE8,000000000061FDE8

Can someone please explain?

1 Answers

On a platform where the number of bits per byte is 8:

1 hexadecimal character represents 4 bits, i.e., "half a byte".

Hence 16 hexadecimal characters represent 8 bytes (not 16 bytes).


Note that generally, the number of bits per byte is define by CHAR_BIT.

So on the theoretical aspect, a byte can consist of something other than 8 bits.

Related