Skip to content

Commit 80a7a52

Browse files
New string functions have been added to std/std.h.
1 parent dd54a0f commit 80a7a52

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

SystemLib/Std/std.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,21 @@ int strlen(const char *str) {
2222
int len = 0;
2323
while (*str++) len++;
2424
return len;
25+
}
26+
27+
void strcpy(char* dst, const char *src) {
28+
while (*src) {
29+
*dst++ = *src++;
30+
}
31+
*dst = 0;
32+
}
33+
34+
void strncpy(char* dst, const char *src, unsigned int n) {
35+
unsigned int i;
36+
for (i = 0; i < n && src[i]; i++) {
37+
dst[i] = src[i];
38+
}
39+
if (i < n) {
40+
dst[i] = 0;
41+
}
2542
}

SystemLib/Std/std.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,7 @@
66
int strcmp(const char *s1, const char *s2);
77
int strncmp(const char *s1, const char *s2, unsigned int n);
88
int strlen(const char *str);
9+
void strcpy(char *dst, const char *src);
10+
void strncpy(char *dst, const char *src, unsigned int n);
911

1012
#endif

0 commit comments

Comments
 (0)