(C++) char
January 7, 2018 · View on GitHub
(C++) char
char is a keyword for a (single-)character data type to store a character literal. std::string can be used to store a collection of char.
int main() { const char c = 'x'; }
Prefer plain char over signed char and unsigned char [1]. Use std::string rather than zero-terminated arrays of chars [2].
References
- Bjarne Stroustrup. The C++ Programming Language (4th edition). 2013. ISBN: 978-0-321-56384-2. Chapter 6.6. Advice. page 169: '[9] Prefer plain char over signed char and unsigned char'
- Bjarne Stroustrup. The C++ Programming Language (4th edition). 2013. ISBN: 978-0-321-56384-2. Chapter 7.8. Advice. page 199: '[7] Use string rather than zero-terminated arrays of chars'