-
Case sensitive
Hi,
I am using a string to compare A and S with tmp which can be a upper case value or a lower case value so i wrote a program like this
<code>
if(strstr(tmp,"A")!=NULL || strstr(tmp,"S")!=NULL) || strstr(tmp,"s")!=NULL || strstr(tmp,"a")!=NULL)
</code>
Is there a different way of writing the case sensitive letter can i use && operator and write a code
-
Well, actually, you're trying to do a case insensitive comparison
The more usual technique would be to convert tmp to upper/lower case (you call as to whether upper or lower), and then do your test. By definition, a string converted to uppercase will never contain lowercase characters and vice versa.
If the case of other parts of tmp matter in later code, convert a copy of tmp to upper/lower case, and do the test against the copy.