07-26-2023, 07:06 PM
Is it possible to perform a switch with a hexadecimal case statement?
for example:
switch (integer) {
case: 1
function();
break;
case: F:
function();
break;
}
g++ complains saying:
example.cpp: In function ‘int main()’:
example.cpp:148:18: error: ‘F’ was not declared in this scope
I assume the compiler is trying to treat `F` as a variable. I know instead of `F` I could just use the value `15` but hex would be more convenient.
Solutions for other control statements would be nice too.
for example:
switch (integer) {
case: 1
function();
break;
case: F:
function();
break;
}
g++ complains saying:
example.cpp: In function ‘int main()’:
example.cpp:148:18: error: ‘F’ was not declared in this scope
I assume the compiler is trying to treat `F` as a variable. I know instead of `F` I could just use the value `15` but hex would be more convenient.
Solutions for other control statements would be nice too.