`char` — C++ Keyword
`char` — C++ Keyword
The char keyword in C++: a character type large enough to hold any member of the basic character set.
`char` — C++ Keyword
The char keyword in C++: a character type large enough to hold any member of the basic character set.
Use reference pages to confirm names, categories, nearby facilities, and the constraints that matter before writing or reviewing code.
charThe basic character type. Large enough to hold any character in the implementation's basic character set. May be signed or unsigned — implementation-defined.
char c;
char c = 'A';
const char* s = "hello";
#include <print>
#include <cctype>
int main() {
char c = 'G';
std::println("{}", c); // G
std::println("{}", static_cast<int>(c)); // 71 (ASCII)
std::println("{}", std::toupper(c)); // 71 (uppercase of 'G' is still 'G')
// Iterating a C-string
const char* word = "hello";
for (const char* p = word; *p != '\0'; ++p) {
std::print("{} ", static_cast<int>(*p)); // 104 101 108 108 111
}
std::println();
}
unsigned char for raw byte manipulation to avoid sign-extension issues.signed char when treating the character as an 8-bit signed integer.char with UTF-8 (std::string/std::string_view) or the char8_t, char16_t, char32_t types.charint main() {
// Pick one facility from this reference page.
// Write the smallest program that exercises its main precondition,
// complexity rule, or lifetime constraint before scaling up.
return 0;
}