summaryrefslogtreecommitdiffstats
path: root/lib/string.c
blob: 4bb1bad7821ce261292f49ff5c6d503404caaecd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include "string.h"

size_t strlen(const char *s) {
    size_t l = 0;
    for(; *s != 0; s++, l++);
    return l;
}

int strcmp(const char *a, const char *b)
{
    size_t i = 0;
    for(; a[i] != 0 && b[i] != 0; i++) {
        if(a[i] != b[i]) return a[i] - b[i];
    }
    return a[i] - b[i];
}