Infinity88
Programmer
The problem is I have an int array, and I need to convert it to a char array so that I can get one byte at a time from it. This is what I tried:
after doing this, this is what I would expect:
Because each int uses 4 bytes. HOWEVER, this is what I actually get:
As if the first 3 bytes were thrown away. This doesnt make any sense to me. Why is the char* being aligned to the least-significant bits of the first (and only the first) int????? Its driving me nuts. VC++ 6.0 w/ SP5
HELP
Code:
int *i = new int[10];
i[0] = 1;
i[1] = 2;
i[2] = 3; //etc
char *c = (char *) i;
Code:
c[0] == 0
c[1] == 0
c[2] == 0
c[3] == 1
c[4] == 0
c[5] == 0
c[6] == 0
c[7] == 2
Code:
c[0] == 1
c[1] == 0
c[2] == 0
c[3] == 0
c[4] == 2
c[5] == 0
c[6] == 0
c[7] == 0
c[8] == 3
HELP