> ## Documentation Index
> Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
> Use this file to discover all available pages before exploring further.

# C++ char

The `char` type in C++ is a fundamental integral data type designed to represent a single character. It is guaranteed by the C++ Standard to be exactly one byte in size (`sizeof(char) == 1`), making it the smallest addressable unit of memory in the language.

Under the hood, a `char` stores an integer value that corresponds to a specific character in the execution character set (typically ASCII). Because it is an integral type, it supports standard arithmetic and bitwise operations.

```cpp theme={"dark"}
// Character literal initialization (enclosed in single quotes)
char letter = 'A'; 

// Integer initialization (ASCII value of 'A')
char ascii_letter = 65; 

// Arithmetic operation on a char
char next_letter = letter + 1; // Results in 'B' (66)
```

## Signedness and Distinct Types

Unlike `int`, where `int` and `signed int` are identical, the C++ standard defines three **distinct** character types. The signedness of a plain `char` is implementation-defined; the compiler dictates whether it behaves as signed or unsigned based on the target architecture and compiler flags.

* `char`: The default type used for character literals. Range depends on the compiler's default signedness.
* `signed char`: Explicitly signed. Guaranteed range of at least -127 to 127 (typically -128 to 127 on modern two's complement systems).
* `unsigned char`: Explicitly unsigned. Guaranteed range of 0 to 255.

```cpp theme={"dark"}
char default_char = 200;          // Value interpretation depends on compiler signedness
signed char negative_char = -50;  // Explicitly signed, valid range
unsigned char raw_byte = 255;     // Explicitly unsigned, maximum 8-bit value
```

## Memory Characteristics

The exact number of bits in a `char` is defined by the `CHAR_BIT` macro found in the `<climits>` header. While the standard requires a minimum of 8 bits, modern POSIX systems and the vast majority of architectures define `CHAR_BIT` as exactly 8 bits.

## Extended Character Types

To support wider character sets and Unicode encodings that exceed the capacity of a standard 8-bit `char`, C++ provides several extended character types, each with specific literal prefixes:

```cpp theme={"dark"}
// Size is implementation-defined (usually 16 or 32 bits)
wchar_t wide_char = L'Ω';       

// C++20: 8-bit UTF-8 character (underlying type is unsigned char)
char8_t utf8_char = u8'A';      

// C++11: 16-bit UTF-16 character (underlying type is uint_least16_t)
char16_t utf16_char = u'ñ';     

// C++11: 32-bit UTF-32 character (underlying type is uint_least32_t)
char32_t utf32_char = U'🌍';    
```

<div
  style={{ 
display: "flex", 
justifyContent: "space-between", 
alignItems: "center", 
maxWidth: "754px", 
padding: "1rem 0",
marginBottom: "24px"
}}
>
  <span style={{ fontWeight: "bold", fontSize: "1.25rem", color: "var(--tw-prose-headings)", fontFamily: "Inter, ui-sans-serif, system-ui, sans-serif" }}>Tired of Poor C++ Skills? Fix That With Deep Grasping!</span>

  <a
    href="https://syntblaze.com"
    target="_blank"
    style={{ 
  marginLeft: "24px",
  textDecoration: "none", 
  backgroundColor: "#007AFF",
  color: "#ffffff", 
  padding: "6px 16px", 
  borderRadius: "16px",
  fontSize: "0.9rem",
  fontWeight: "600",
  textAlign: "center",
  transition: "background-color 0.2s ease"
}}
  >
    Learn More
  </a>
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/skill-tracking.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=b9b0305c93bb501c9e767b5c76c88835" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/skill-tracking.png" />

  <img src="https://mintcdn.com/syntblazellc/23tyuOzaWS88qFlc/images/nuggets.png?fit=max&auto=format&n=23tyuOzaWS88qFlc&q=85&s=c86c80197299762989e9b882419b2109" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/nuggets.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/bite-sized-exercises.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=a65f9a38c37ff28ab73ed783c53c60e3" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/bite-sized-exercises.png" />
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap", marginTop: "12px" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/mastery-chain.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=748a1763454713e679260fbb95f154a2" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/mastery-chain.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-previews.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=242f61448ff5dd6deaaab2dccc13b507" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-previews.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-explanations.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=cf0fc1c31f9cd0fc26716781be05fbc9" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-explanations.png" />
</div>
