stricmp, _fstricmp
Compares one string to another, without case sensitivity.
Defined in header <string.h>
Syntax
#include <string.h>
Near version: int stricmp(const char *sl, const char *s2);
Far version: int far _fstricmp(const char far *sl, const char far *s2)
Portability
| DOS | UNIX | Windows | ANSI C | C++ only |
|---|---|---|---|---|
| ■ | ■ |
Remarks
stricmp performs an unsigned comparison of si to s2, starting with the first character in each string and continuing with subsequent characters until the corresponding characters differ or until the end of the strings is reached. The comparison is not case sensitive.
It returns a value (< 0, 0, or > 0) based on the result of comparing si (or part of it) to s2 (or part of it).
The routines stricmp and strcmpi are the same; strcmpi is implemented through a macro in string.h that translates calls from strcmpi to stricmp. Therefore, in order to use strcmpi, you must include the header file string.h for the macro to be available.
Return value
stricmp returns an int value that is
< 0 if s2 is less than s2 == 0 if si is the same as s2 > 0 if s2 is greater than s2
See also
Example
#include <string.h>
#include <stdio.h>
int main(void)
{
char *bufl = "BBB", *buf2 = "bbb";
int ptr;
■ ptr = strcmpi (buf2, bufl);
if (ptr > 0)
printf ("buffer 2 is greater than buffer l\n"
if (ptr < 0)
printf("buffer 2 is less than buffer l\n");
if (ptr == 0)
printf ("buffer 2 equals buffer l\n");
return 0;
Differences from modern implementations
Nothing recorded yet.
Modern references
These are search links, not yet checked by hand.
Extraction notes
- heading `stricmp, _fstricnnp` read as `stricmp, _fstricmp`
Stable link: /3.1/string.h/stricmp/
· short form /3.1/stricmp/