On this page
char
Prev: void | Up: builtins | Next: int
Rel: Arrays & C Strings, ctype.h
Ref: cppreference — char
Tags: #public #prog #c #builtins #tier/core
Availability
Built-in (Built-in Type) — requires no #include header.
Syntax & Overview
char | signed char | unsigned char
Smallest addressable unit (always sizeof(char) == 1). Signedness of plain char is implementation-defined.
Notes & Pitfalls
- Signedness of plain
charis implementation-defined (signed on x86-64 Linux/macOS, unsigned on ARM Linux): Always useunsigned charfor raw bytes and cast(unsigned char)cbefore calling<ctype.h>functions.
Example
#include <assert.h>
#include <ctype.h>
int main(void) {
char ch = 'a';
assert(toupper((unsigned char)ch) == 'A');
}
Linked from
Related notes
- tuts/c/builtins/int Linked here; links to this page; shared tags: #builtins, #c, #prog, #tier
- tuts/c/builtins/void Linked here; links to this page; shared tags: #builtins, #c, #prog, #tier
- tuts/c/builtins Linked here; links to this page; shared tags: #builtins, #c, #prog
- tuts/c/fundamentals/arrays_and_strings Linked here; shared tags: #c, #prog
- tuts/c/stdlib/ctype Linked here; shared tags: #c, #prog
- tuts/c/builtins/__FILE__ shared tags: #builtins, #c, #prog, #tier
- tuts/c/builtins/__func__ shared tags: #builtins, #c, #prog, #tier
- tuts/c/builtins/__LINE__ shared tags: #builtins, #c, #prog, #tier
- tuts/c/builtins/__STDC_VERSION__ shared tags: #builtins, #c, #prog, #tier
- tuts/c/builtins/_Alignof shared tags: #builtins, #c, #prog, #tier