I cant figure out how to use string or chars in a switch any pointers
I cant figure out how to use string or chars in a switch any pointers
Strings cannot be used in a switch statement. chars can. Its just a limitation of the c++.
Can i get a example of how to use a char cause ive tried
Code:char c = 'b'; switch(c) { case 'a': ... case 'b': ... case 'c': ... }
Don't forget that you will need to break out of your switch case.
Code:char a = 'b'; switch(a) { case 'a': //do something break; case 'b': // do something break; default: // do something }
includes breaks .Code:...
This only works for single characters, though. Not for C-style strings.
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law