int length = 256 * getch() + getch();
int length = 256 * 0x00 + 0x80;
int length = 256 * 0x80 + 0x00;
Consider two functions f() and g(). In C and C++, the + operator is not a sequence point, and therefore in the expression f()+g() it is possible that either f() or g() will be executed first.
unsigned char higherBits = getch();unsigned char lowerBits = getch();int length = 256 * higherBits + lowerBits;