strncasecmp() — Case-insensitive string comparison

Standards

Standards / Extensions C or C++ Dependencies

XPG4.2
Single UNIX Specification, Version 3

both  

Format

#define  _XOPEN_SOURCE_EXTENDED 1
#include <strings.h>

int strncasecmp(const char *string1, const char *string2, size_t n);

General description

The strncasecmp() function compares, while ignoring differences in case, the string pointed to by string1 to the string pointed to by string2. At most n characters will be compared.

The string arguments to the function should contain a NULL character (\0) marking the end of the string.

The strncasecmp() function is locale-sensitive.

Returned value

strncasecmp() returns a value indicating the relationship between the strings, while ignoring case, as follows:
Value
Meaning
< 0
String pointed to by string1 is less than string pointed to by string2.
= 0
String pointed to by string1 is equal to string pointed to by string2.
> 0
String pointed to by string1 is greater than string pointed to by string2.

There are no errno values defined.

Related information