4 ms·
In a char, not in a byte. Byte != char
by Iwan-Zotow 2y ago
In a char, not in a byte. Byte != char
- AStonesThrow 2y agoA common programming error in C is reading input as char rather than int. https://man7.org/linux/man-pages/man3/fgetc.3.html https://man7.org/linux/man-pages/man3/fgetc.3.html fgetc(3) and its companions always return character-by-character input as an int, and the reason is that EOF is represented as -1. An unsigned char is unable to represent EOF. If you're using the wrong return value, you'll never detect this condition. However, if you don't receive an EOF, then it should be perfectly fine to cast the value to unsigned char without loss of precision.
- znkr 2y agoNope: https://isocpp.org/wiki/faq/intrinsic-types#bytes-review https://isocpp.org/wiki/faq/intrinsic-types#bytes-review
- gpderetta 2y agoIn C and C++ a byte and a char are the same size by definition. Don't confuse a byte with an octet.