4 ms·
> chars are guaranteed to be 1 byte No they are not, assuming a byte as defined in ISO/IEC 80000-13 (8 bits, the most common accepted definition). In fact othe
by 4ad 13y ago
> chars are guaranteed to be 1 byte
No they are not, assuming a byte as defined in ISO/IEC 80000-13 (8 bits, the most common accepted definition). In fact other types are defined in terms of the size of char, and sizeof(char) is always 1 by definition. These are not 8 bit bytes though. Some machines don't have byte addressing, for example DSPs. CHAR_BIT will tell you how many bits are in a char.
- level09 13y agoSend a pull request :)
- TheCoelacanth 13y ago> assuming a byte as defined in ISO/IEC 80000-13 C uses a different definition of byte. The C standard defines the size of a char as 1 byte.
- 4ad 13y agoWhat is defined as a byte in the C standard is irrelevant to this article. A person reading this awful article(?) hoping to learn C wouldn't be aware of the C-standard definition precisely because he doesn't know C! He would only be familiar with the common definition of 8 bit bytes. ISO/IEC 80000-13 defines 8 bit bytes precisely because this is the common definition.
- TheCoelacanth 13y agoIf you are going to use the common definition instead of the C-standard definition, why not use the common implementation characteristics of C as well? A char is one byte both in the context of the standard and in the context of common usage. It's only when you mix the two contexts haphazardly that the two aren't the same size.