Here\'s an interesting one. I\'m writing an AES encryption algorithm, and have managed to get it making accurate encryptions. The trouble comes when I attempt to write the r
Cast your value to unsigned char
first:
char input = 250; // just an example
unsigned int n = static_cast(input); // NOT: "unsigned int n = input;"
// ^^^^^^^^^^^^^^^^^^^^^^^^^^
The problem is that your char
happens to be signed, and so its value is not the "byte value" that you want -- you have to convert to unsigned char
to get that.