c++ switch case string code example
Example 1: switch c++
switch(expression) {
case x:
// code block
break;
case y:
// code block
break;
default:
// code block
}
Example 2: c++ switch string
switch(str2int("my string"))
{
case str2int("my string")):
{
}
break;
}
constexpr unsigned int str2int(const char* str, int h = 0)
{
return !str[h] ? 5381 : (str2int(str, h+1) * 33) ^ str[h];
}