mirror of
https://github.com/gbowne1/ClassicOS.git
synced 2026-03-09 08:25:19 -07:00
Compare commits
4 Commits
56faa3143d
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 3e6f8d0072 | |||
|
|
bfc9911a85 | ||
|
|
9d394d984b | ||
|
|
45abf9418b |
@@ -10,5 +10,6 @@ extern void* memset(void* dst, int c, size_t n);
|
||||
|
||||
extern size_t strlen(const char *s);
|
||||
extern int strcmp(const char *s1, const char *s2);
|
||||
extern char *strncpy(char *dst, const char *src, size_t n);
|
||||
|
||||
#endif // CLASSICOS_KLIBC_STRING_H
|
||||
|
||||
@@ -105,3 +105,19 @@ 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