LibC: Add strcpy function to string.h

This commit is contained in:
g1n 2021-09-08 15:52:53 +03:00
parent 4462c2a714
commit fc18048e2f
3 changed files with 12 additions and 0 deletions

View File

@ -41,6 +41,7 @@ string/memmove.o \
string/memset.o \
string/strlen.o \
string/strcmp.o \
string/strcpy.o \
HOSTEDOBJS=\
$(ARCH_HOSTEDOBJS) \

View File

@ -15,6 +15,7 @@ void* memmove(void*, const void*, size_t);
void* memset(void*, int, size_t);
size_t strlen(const char*);
int strcmp(const char *str1, const char *str2);
char *strcpy(char *dest, const char *src);
#ifdef __cplusplus
}

10
libc/string/strcpy.c Normal file
View File

@ -0,0 +1,10 @@
#include "string.h"
char *strcpy(char *dest, const char *src) {
size_t i;
for (i = 0; i < strlen(src) && src[i] != '\0'; i++)
dest[i] = src[i];
dest[i] = '\0';
return dest;
}