Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

strncmp - compare two substrings

&pagelevel(4)&pagelevel

Syntax

#include <string.h>

int strncmp(const char *s1, const char *s2, size_t n);

Description strncmp() compares strings s1 and s2 lexically up to a maximum length of n, e.g.

strncmp("Sie","Siemens",3)

returns 0 (equal), because the first three characters of both arguments match one another.

Return val.

Integer value:

< 0

= 0

> 0

In the first n characters, s1 is lexically less than s2.

In the first n characters, s1 and s2 are lexically equal.

In the first n characters, s1 is lexically greater than s2.

Notes

Strings terminated with the null byte (\0) are expected as arguments.

The collating sequence is based on the EBCDIC character set.

See also

strcmp(), string.h.