can I do case-switch for string?

This is a simple one, you could do switch on the first char as these are unique

switch(tolower(answer[0]))
{
  case 'y': // yes
    ...
    break;  
  case 'n': // no
    ...
    break;  
  case 'o': // ok
    ...
    break;  
  case 'b': // bad
    ...
    break;  
  default:  // ignore the rest
}
1 Like