If you express the result in hexadecimal (%x), you can see that:
858927408 = 0x33323130
0x33
is the ascii code for '3'
0x32
is the ascii code for '2'
0x31
is the ascii code for '1'
0x30
is the ascii code for '0'
So you just display the memory storing 0123456...
But since your processor is little endian, you see the codes inverted.
In memory, you have (in hexa)
30 31 32 33 34 35 36 37 38 # 0 1 2 3 4 5 6 7 8
39 30 31 32 33 34 35 36 37 # 9 0 1 2 3 4 5 6 7
38 39 00 # 8 9\0
In the printf("%d...")
, you read the 4 first bytes as a little endian integer, So it display the result of 0x33*0x1000000 + 0x32*0x10000 +0x31*0x100 +0x30
With %c
, things are different:
If you write printf("%c", pp[0])
, you will try to print ONE character from 0x33323130
, so 0x30
is retain (in your case, might be an UB in some cases, I'm not sure) so it display "0" which ascii code is 0x30
If you write printf("%c", pp[1])
, you will try to print ONE character from 0x37363534
, so 0x34
is retain so it display "4" which ascii code is 0x34