Skip to content
Snippets Groups Projects
Commit bd9de5ec authored by Paul Sokolovsky's avatar Paul Sokolovsky
Browse files

lib/libc/string0: Add strncpy() implementation.

parent 5302c3e8
No related branches found
No related tags found
No related merge requests found
...@@ -169,6 +169,15 @@ char *strcpy(char *dest, const char *src) { ...@@ -169,6 +169,15 @@ char *strcpy(char *dest, const char *src) {
return dest; return dest;
} }
char *strncpy(char *dest, const char *src, size_t dest_sz) {
char *d = dest;
while (*src && --dest_sz) {
*d++ = *src++;
}
*d = '\0';
return dest;
}
// needed because gcc optimises strcpy + strcat to this // needed because gcc optimises strcpy + strcat to this
char *stpcpy(char *dest, const char *src) { char *stpcpy(char *dest, const char *src) {
while (*src) { while (*src) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment