3 ms·
"Incidentally, it is a common misconception that if c is a character variable, one can obtain the unsigned integer equivalent of c by writing (unsigned) c. This
by ouah 11y ago
"Incidentally, it is a common misconception that if c is a character variable, one can obtain the unsigned integer equivalent of c by writing (unsigned) c. This fails because a char quantity is converted to int before any operator is applied to it, even a cast. Thus c is converted first to a signed integer and then to an unsigned integer, with possibly unexpected results."
The "even a cast" part is wrong. The usual arithmetic conversions (including the integer promotion) is not done with the cast operation in C.