The C language standard defines a virtual machine where all objects occupy an integer number of abstract storage units consisting of a fixed number of bits (specified by the CHAR_BIT macro in limits.h). Each repository must be uniquely addressable. A storage unit is defined as the amount of memory occupied by one character from the basic character set 1 . Thus, by definition, a char type size is 1.
Ultimately, these abstract storage units must be displayed on physical equipment. Most common architectures use individually addressed 8-bit bytes, so char objects are usually mapped to one 8-bit byte.
Usually.
Historically, native byte sizes have been between 6 and 9 bits. In C, the char type must have a width of at least 8 bits to represent all characters in the base character set, so to support a machine with 6-bit bytes, the compiler may have to map the char object to two native bytes of the machine, with CHAR_BIT being 12. sizeof (char) is still 1, so types with size N will map to 2 * N native bytes.
1. The basic character set consists of all 26 English letters in upper and lower case, 10 digits, punctuation and other graphic characters and control characters, such as newline characters, tabs, form feeds, etc., all of which are convenient fit in 8 bits.
John bode
source share