PatchworkOS
Loading...
Searching...
No Matches
strncmp.c
Go to the documentation of this file.
1#include <string.h>
2
3int strncmp(const char* s1, const char* s2, size_t n)
4{
5 while (n && *s1 && (*s1 == *s2))
6 {
7 ++s1;
8 ++s2;
9 --n;
10 }
11
12 if (n == 0)
13 {
14 return 0;
15 }
16 else
17 {
18 return (*(unsigned char*)s1 - *(unsigned char*)s2);
19 }
20}
int strncmp(const char *s1, const char *s2, size_t n)
Definition strncmp.c:3