Is there any way to make the strcmp ignore the difference between capital letters and lower case? My sort is working but it is putting all the words with capitals first then the lower case.
Thanks
Is there any way to make the strcmp ignore the difference between capital letters and lower case? My sort is working but it is putting all the words with capitals first then the lower case.
Thanks
You could put everything in uppercase to begin with (toupper or tolower, depending on how you feel)
-Govtcheez
[email protected]
Use strcasecmp() (/stricmp).
>Use strcasecmp() (/stricmp).
These functions are not part of the ANSI standard.
If you don't mind writing you own compare function, you can get that functionality:
Just call mystrcmp as you would call strcmp.Code:int mystrcmp(char *o, char *n) { while (*o) { if (tolower(*o) == tolower(*n) ) { o++; n++; } else { return(-1); } } if (! *n) // if *n isn't null when *o is, the strings are different lengths return(0); else return(-1); }
clu82
no real need
use the tolower() function ( i think its defined in string.h)
this will convert the string to lower case. If you wish to preserve case - copy the string convert that to lower check it and then use your original which still be in its original case
Monday - what a way to spend a seventh of your life
tolower() will convert 1 character at a time.
Won't you will still need to write some kind of loop to check the string 1 character at a time?
clu82