In c, to search for the letters a-z, I can do the following loop:
char s[10];
int c;
int has_letter = 0;
for (int i=0; (c=s[i])!='\0'; i++) {
if (c>='a' && c<='z')
has_letter = 1;
}
However, what the are chars are not contiguous, for example:
// see if any of the following letters are in it: 'adiuo'
char s[10];
int c;
int has_letter = 0;
for (int i=0; (c=s[i])!='\0'; i++) {
if (c=='a' || c=='d' || c=='i' || c=='u' || c=='o')
has_letter = 1;
}
Is there a way to simplify that construction? For example, doing something like:
char s[10];
int c;
int has_letter = 0;
for (int i=0; (c=s[i])!='\0'; i++) {
if (c in "adiuo") // possible to do something like this?
has_letter = 1;
}