Header File
string.h, mbstring.h
Category
Memory and String Manipulation Routines
Prototype
int strnicmp(const char *s1, const char *s2, size_t maxlen);
int _wcsnicmp(const wchar_t *s1, const wchar_t *s2, size_t maxlen);
int _mbsnicmp(const unsigned char *s1, const unsigned char *s2, size_t maxlen);
Description
Compares a portion of one string to a portion of another, without case sensitivity.
strnicmp performs a signed comparison of s1 to s2, for a maximum length of maxlen bytes, 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 s1 (or part of it) to s2 (or part of it).
Return Value
less than s2 |
< 0 |
the same as s2 |
== 0 |
greater than s2 |
> 0 |
Example
#include <string.h> #include <stdio.h> int main(void) { char *buf1 = "BBBccc", *buf2 = "bbbccc"; int ptr; ptr = strnicmp(buf2, buf1, 3); if (ptr > 0) printf("buffer 2 is greater than buffer 1\n"); if (ptr < 0) printf("buffer 2 is less than buffer 1\n"); if (ptr == 0) printf("buffer 2 equals buffer 1\n"); return 0; }
Portability
|
POSIX |
Win32 |
ANSI C |
ANSI C++ |
strnicmp |
|
+ |
|
|
_mbsnicmp |
|
+ |
|
|
_wcsnicmp |
|
+ |
|
|
Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
|
What do you think about this topic? Send feedback!
|