add strcpy implementation

This commit is contained in:
Borna Šoštarić
2026-01-28 21:55:01 +01:00
parent 9d394d984b
commit bfc9911a85
2 changed files with 16 additions and 0 deletions

View File

@@ -106,3 +106,18 @@ int strcmp(const char *s1, const char *s2) {
return d;
}
char *strncpy(char *dst, const char *src, size_t n) {
char *q = dst;
const char *p = src;
char ch;
while (n) {
n--;
*q++ = ch = *p++;
if (!ch) break;
}
memset(q, 0, n);
return dst;
}