You work in little-endian vs big-endian representation of numbers.
Let's look at the 4-btyes values โโthat are used to represent a 4-byte integer.
+ ---- + ---- + ---- + ---- +
| N1 | N2 | N3 | N4 |
+ ---- + ---- + ---- + ---- +
In a large-end view, these 4 bytes represent:
N1*2^24 + N2*2^16 + N3*2^8 + N4
In a low-intensity representation, these 4 bytes represent:
N1 + N2*2^8 + N3*2^16 + N4*2^24
In your case.
N1 = 'A' (65 decimal) N2 = 0 N3 = 0 N4 = 0
Since the value of the whole you get is 65 , you have a little idea of โโthe end. If you want to process these numbers, for example, a big-endian view, you can use the following:
#include <stdio.h> int main(int argc, char *argv[]) { int i; char nameString[4] = {'A'}; int name = 0; for ( i = 0; i < 4; ++i ) { name = (name << 8) + nameString[i]; } printf("%d\n", name); printf("%X\n", name); return 0; }
The output I get with the above code is:
1090519040
41000000
source share