I need a case insensitive string comparison function similar to strcmp...where can I view the code sample of it?
please help
thank you
I need a case insensitive string comparison function similar to strcmp...where can I view the code sample of it?
please help
thank you
It's simple enough to make your own. Just loop through each string changing the characters to lower case, then use strcmp(). Well, that's one way, there are more...Originally posted by Unregistered
I need a case insensitive string comparison function similar to strcmp...where can I view the code sample of it?
please help
thank you
You'll need to use isupper() and tolower() at least.....
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]
Actually, you'll need only 'toupper' or 'tolower' only. One or the other. No need for both, no need to even bother checking. Just run a loop and compare tolower(letter1) with tolower(letter2).Originally posted by Hammer
You'll need to use isupper() and tolower() at least.....
You can pass tolower a lower case value, or hell, even a number or punctuation mark, and it'll just return any non-upper case characters as they were, unchanged. The only thing it changes is upper case.
Quzah.
Hope is the first step on the road to disappointment.
or if your homework does not require you to write your own you could use
lstrcmpi() (windows version of stricmp() )
if(lstrcmpi(sString1,sString2)==0)//they are the same
Last edited by novacain; 06-28-2002 at 02:29 AM.
"Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
Friedrich Nietzsche
"I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
George Best
"If you are going through hell....keep going."
Winston Churchill
>just use stricmp....
Why? The functionality is trivial to program and far more portable if done correctly. Remember that stricmp is not a standard function, so not all implementations will have it. With a little thought and effort, you can write your own function in ISO conforming code and not have to worry about portability problems.
-Prelude
My best code is written with the delete key.