Start here · Essential guide
How to Switch on a String in C++
C++ does not let you switch on a std::string. See why, then compare if else chains, enum lookups and single-character switches with code examples.
Strings, Containers and Memory
Workarounds for using strings in a switch, plus switch basics in C.
Start here · Essential guide
C++ does not let you switch on a std::string. See why, then compare if else chains, enum lookups and single-character switches with code examples.
How to write a switch case in C, step by step: the syntax, the role of break and default, a full working program, and common mistakes to avoid.
C has no string type. A C string is a char array ending in a null character. Learn how it's stored, how to measure it and how to use it safely.
A switch statement picks one block of code to run by matching a value against case labels. Learn how it works, how it compares with if else, and its limits.
C has 32 keywords in the original standard, from auto and break to while. Here's the full list, grouped by purpose, and why you can't use them as names.
Related topics