Home > Back-end >  Char pointer of type size of 4, why just 1 plus 1
Char pointer of type size of 4, why just 1 plus 1

Time:11-21

Char * PC; PC=PC + 1; Sizeof (char)=1 byte, after PC=PC + 1 PC added 1 byte

CodePudding user response:

PC + 1 is a byte (address be a byte)
Pc++ will add 4 bytes (address forward a pointer)
There is a difference between this, otherwise want to address offset 1 byte can not be achieved

CodePudding user response:

T * p;
P=p + 1;
Mean to move the p a sizeof (T) position
If char * * p whether p=p + 1, or p++, p moving back a sizeof (char *) is also moving 4 bytes (32-bit), 8 bytes (64 - bit systems)

  • Related