mirror of
https://github.com/gbowne1/ClassicOS.git
synced 2026-02-11 21:35:20 -08:00
add strcpy implementation
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user