Names specified here
Name Description Notes Source Availability
ATOMIC_CHAR_LOCK_FREE Lock-free property of type atomic_char ? M <stdatomic.h> C11
atomic_char Atomic character type ? T <stdatomic.h> C11
atomic_schar Atomic character type ? T <stdatomic.h> C11
atomic_uchar Atomic character type ? T <stdatomic.h> C11
CHAR_BIT Number of bits in unsigned char L M <limits.h> C89 C90 C95 C99 C11
CHAR_MAX Maximum value of char L M <limits.h> C89 C90 C95 C99 C11
CHAR_MIN Minimum value of char L M <limits.h> C89 C90 C95 C99 C11
char Character type L T Native C89 C90 C95 C99 C11
SCHAR_MAX Maximum value of signed char L M <limits.h> C89 C90 C95 C99 C11
SCHAR_MIN Minimum value of signed char L M <limits.h> C89 C90 C95 C99 C11
signed char Character type L T Native C89 C90 C95 C99 C11
UCHAR_MAX Maximum value of unsigned char L M <limits.h> C89 C90 C95 C99 C11
unsigned char Character type L T Native C89 C90 C95 C99 C11

In C, types are built on the concept of a byte, a sequence of 8 or more bits treated as a unit. It is the smallest unit of data that a C program can manipulate, and the smallest addressable unit of memory. The memory that holds the program's data is considered to be made of distinctly addressable bytes. All types have an underlying representation as a sequence of bytes.

The type that represents a byte is unsigned char, which has a range from zero to UCHAR_MAX, which is at least [0, +255]. Each bit has the value +2n, where n runs from zero to one less than CHAR_BIT (which therefore must be at least 8). There is no sign bit, and there are no padding bits. Use %u, %o, %x or %X with printf to print an unsigned char as a number. Use %hhu, %hho or %hhx with scanf to scan an unsigned char.

The type signed char has the same number of bits as unsigned char, and runs from SCHAR_MIN to SCHAR_MAX, which is at least [−127, +127]. There are no padding bits. Use %d or %i with printf to print a signed char as a number. Use %hhd or %hhi with scanf to scan a signed char.

The type char has exactly the same representation as either unsigned char or signed char, and it is the type that a character should be stored in. It can be either a signed or unsigned type, with the range CHAR_MIN to CHAR_MAX. CHAR_MIN will be negative if it is signed. Arrays of char are used to represent sequences of single-byte and multibyte characters, and are often passed around by reference using char *.

Use "%c" to print a single char with printf, or to scan a single character with scanf. The field width allows a specific number of characters to be scanned.

The types char, unsigned char and signed char are the character types. The sizeof operator yields 1 for all character types. char *, unsigned char * and signed char * can be punned safely with void *, when used with va_arg, for example.

atomic_uchar is an alias for _Atomic unsigned char. atomic_schar is an alias for _Atomic signed char. atomic_char is an alias for _Atomic char. These types are lock-free always if ATOMIC_CHAR_LOCK_FREE is 2, sometimes if 1, and never if 0.


CHaR
Sitemap Supported
Site format updated 2024-06-05T22:37:07.391+0000
Data updated 1970-01-01T00:00:00.000+0000
Page updated 2024-06-10T19:54:01.045+0000