hello i am trying to compile my program but the compiler does not accept strcmpi()
what is another function i can use???
Printable View
hello i am trying to compile my program but the compiler does not accept strcmpi()
what is another function i can use???
Perhaps, you have a typo. TryAlthough, there is a safer functionCode:strcmp()
Code:strncmp()
strcmpi() is a case-insensitive version of strcmp(). If your compiler's library doesn't have strcmpi(), then you'll either have to write your own, or settle for a case-sensitive string comparison. The macros/functions in <ctype.h> such as tolower(3) should be useful in writing a portable strcmpi() implementation.
Some compilers have stricmp() instead. But the best idea is to write your own version.
so how do i write my own version to it?
There's also strcasecmp :)
Well, a good start would be to iterate through each string, comparing each character one at a time, but instead of just comparing them for equality, pass each character through either toupper or tolower, to make it case insensitive.
And _stricmp(), for MSVC. :)