welibc
A clear, secure, and well documented standard C library
Functions
strncmp.c File Reference

Defines the strncmp function. More...

#include <string.h>
Include dependency graph for strncmp.c:

Go to the source code of this file.

Functions

int strncmp (const char *s1, const char *s2, size_t n)
 Compares the strings pointed to be s1 and s2. More...
 

Detailed Description

Defines the strncmp function.

Definition in file strncmp.c.

Function Documentation

◆ strncmp()

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

Compares the strings pointed to be s1 and s2.

Parameters
*s1The first string to be compared
*s2The second string to be compared
nMaximum number of characters to be compared

The strncmp function compares note more than n characters (characters that follow a null character are not compared) from the array pointed to by s1 to the array pointed to by s2.

Returns
Integer indicating if s1 is greater than, equal to, or less than s2
Return values
>0s1 is greater than s2 or no comparison could be made
0s1 is equal to s2
<0s1 is less than s2

Definition at line 56 of file strncmp.c.

References memcmp(), and strlen().

Referenced by strstr().

Here is the call graph for this function:
Here is the caller graph for this function: