Why in the world would it process from right to left ? who does math in that order, especially addition !
1 2
|
int a = 1;
cout << a << a++ << a++ << a << endl;
|
I would assume the output would be
1 1 2 3
but noooooo
3 2 1 3
is the output because from right to left it does the ++ then rest LAST.
Does anyone else see this as incredibly retarded or is it just me ?
the reason this came up is I have an array called buffer and an index names i, a function called mk16 which takes two unsigned char and a mask and converts them to an unsigned int.
i = 16; // this is the index at where my length variable exists, after the length is the X number of bytes.
length = mk16(buffer[i++], buffer[i++], 0x0FFF);
for(int a = 0; a < length; a++)
cout << buffer[i++];
nice right ? simple clean effective, doesnt work cause of how the ++ are sorted right to left.