I wanted to know if there is a way in c to check, for example in a for function if a variable is equal or unequal to certain characters without having to repeat each time an equality check. If I am not wrong, checking equality this way is incorrect:
if (a == ('\n' || '\t' || ' ' || ',' || '.' || ';' || ':' || '!' || '?')) {
execute certain action;
}
you would need to have an endless chain of a == '\n' || a == '\t' || ...
. I was wondering if there was a shorter (and cleaner) way to check equality for a list of symbols, because when instead of a
you have something more descriptive, this code becomes a mess.
Also, if you could explain to me why the first part is wrong, I would be grateful.