gbdk-2020 | GameBoy Development Kit |
| download: https://git.y1.nz/archives/gbdk.tar.gz | |
| README | Files | Log | Refs | LICENSE |
gbdk-lib/libc/strncmp.c
1 #include <string.h>
2
3 /*
4 * Compare strings (at most n bytes):
5 * s1>s2: >0
6 * s1==s2: 0
7 * s1<s2: <0
8 */
9
10 int strncmp(const char *s1, const char *s2, int n) {
11 while ((n > 0) && (*s1 == *s2++)) {
12 if (*s1++ == '\0') return 0;
13 n--;
14 }
15 return (n == 0 ? 0 : *s1 - *--s2);
16 }
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.