strnicmp, _fstrnicmp
raw OCR
Compares a portion of one string to a portion of another, without case sensitivity.
Defined in header <string.h>
Syntax
#include <string.h>
Near version: int strnicmp(const char *sl, const char *s2, size_t maxlen);
Far version: int far _fstrnicmp(const char far *sl, const char far *s2,
size_t maxlen)
Portability
| DOS | UNIX | Windows | ANSI C | C++ only |
|---|---|---|---|---|
| ■ | ■ |
Remarks
| strnicmp performs a signed comparison of si to s2, for a maximum | length |
of maxlen bytes, starting with the first character in each string and continuing with subsequent cliaracters 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).
Retum value
strnicmp 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
Example
#include <string.h>
#include <stdio.h>
int main(void)
{
char *bufl = "BBBccc", *buf2 = "bbbccc";
int ptr;
ptr = strnicmp (buf2, bufl, 3);
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 `strnicmp, Jstrnicmp` read as `strnicmp, _fstrnicmp`
Stable link: /3.1/string.h/strnicmp/
· short form /3.1/strnicmp/