DE> TH> strcmpi() is an unsigned version of strcmp().
DE> Right. stricmp is the case insensitive version of strcmp
DE> that should appear in all standard libraries.
And likely would, if it were standard.
As it is, all the tools necessary to make a strcmpi() are
present within the ANSI standard library. One method might
look something like this:
#include
#include
#include
#include
char *uppercase(char *u)
{
char *s = u;
if(s)
for(;*s; s++)
*s = (char)toupper(*s);
return u;
}
int nocase_cmp(const char *a, const char *b)
{
char *cA, *cB;
int result = 1;
if(a && b)
{
cA = malloc(strlen(a));
cB = malloc(strlen(b));
if(cA && cB)
{
strcpy(cA, a);
uppercase(cA);
strcpy(cB, b);
uppercase(cB);
result = strcmp(cA, cB);
free(cA);
free(cB);
}
}
return result;
}
int main(int argc, char **argv)
{
if(argc > 2)
{
printf("These strings are%s equal.\n",
(0 == nocase_cmp(argv[1], argv[2])) ? "" : "n't");
}
else
puts("usage: nocascmp [STRING1] [STRING2]");
return 0;
}
Of course, you would find this type of process assigned to
the == operator within a class in a C++ implementation, so
that you need only write something such as
if(Astring == Bstring)
and the result would be automatically forthcoming in any
two strings belonging to your string class.
Some commonly used functions are NOT in the standard, but
are easily implemented using those functions which ARE
supplied in the standard. They are there, but some assembly
may be required in order to use them. :)
> ] You're trying to make me paranoid, but I'm on to your tricks
---
---------------
* Origin: *YOPS ]I[* 3.1 GIG * RA/FD/FE RADist * Milwaukee, WI (1:154/750)
|