In C, char is the narrow integer type used for printable characters and text. It occupies exactly one byte, although its signedness can depend on the platform. section 5.2 section 12.1
One byte by definition
char letter = 'A'; sizeof(char) == 1 The declaration uses char for character data, while sizeof(char) is defined as 1. When letter participates in arithmetic, it is promoted to signed int before the operation. section 5.2 section 12.1
Keep these distinctions explicit:
- Use char for character and string data. section 12.1
- Treat char as distinct from signed char and unsigned char, even when implementations give types the same class or precision. section 5.2
- Use unsigned char as the byte-level view of an object; every object can be viewed as unsigned char[sizeof A]. section 12.1
- Remember that narrow integer types are promoted to signed int before arithmetic or comparison. section 5.2
Table 5.1 Base types according to the four main type classes. Types with a gray background don’t allow for arithmetic; they are promoted before doing arithmetic. Type char is special since it can behave like unsigned or signed, depending on the platform. All types in this table are considered to be distinct types, even if they have the same class and precision.
| Class | Systematic name | Other name | Rank | |
|---|---|---|---|---|
| Integers | Unsigned | bool | _Bool | 0 |
unsigned char | 1 | |||
unsigned short | 2 | |||
unsigned int | unsigned | 3 | ||
unsigned long | 4 | |||
unsigned long long | 5 | |||
| [Un]signed | char | 1 | ||
| Signed | signed char | 1 | ||
signed short | short | 2 | ||
signed int | signed or int | 3 | ||
signed long | long | 4 | ||
signed long long | long long | 5 | ||
| Floating point | Real | float | ||
double | ||||
long double | ||||
| Complex | float _Complex | float complex | ||
double _Complex | double complex | |||
long double _Complex | long double complex | |||
Use the base-type table to compare char with the other narrow types and to see its platform-dependent signedness. section 5.2




