mardi 30 mai 2017

How to search a char in a char array in if condition statement

Is there any function which can help me do the following in an efficient way?

char ch = '+';
if (( ch == '+') || (ch == '-') || (ch == '*'))
{
    //do something
}

Since have to check this several times in my code, I would prefer if there was any to do it similar to

char arr ={'+','-','*'};
if (ch in arr)
{
    //do something 
}

Aucun commentaire:

Enregistrer un commentaire