X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/37fb1e9cee287c9ae8c065ff517c508eb5f9d7dd..05b7549a0f980efa33265a091a5174a78851ce05:/lunaix-os/libs/klibc/string/strcpy.c diff --git a/lunaix-os/libs/klibc/string/strcpy.c b/lunaix-os/libs/klibc/string/strcpy.c new file mode 100644 index 0000000..1258606 --- /dev/null +++ b/lunaix-os/libs/klibc/string/strcpy.c @@ -0,0 +1,23 @@ +#include + +char* +strcpy(char* dest, const char* src) { + char c; + unsigned int i = 0; + while ((c = src[i])) + { + dest[i] = c; + i++; + } + dest[i] = '\0'; + return dest; +} + +char* +strncpy(char* dest, const char* src, size_t n) { + char c; + unsigned int i = 0; + while ((c = src[i]) && i < n) dest[i++] = c; + while (i < n) dest[i++] = 0; + return dest; +} \ No newline at end of file