vendredi 30 septembre 2016

Specify a range of ASCII lowercase chars in C++

I am writing a program that takes a char and compares it to see if it's in a range of certain chars. For instance, if the char I get is an n I go to state 3, if its a - m or o - z I go to state 4. I'm new to C++ so I'm still learning.

Can I say something like:

char c = file.next_char();
...
if (c in 'a'...'m', 'o'...'z')
{
   state = 3;
} else {
   state = 4;
}

Aucun commentaire:

Enregistrer un commentaire