2018-06-25 10:28:13 +03:00
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
char * strncpy(char * dest, const char * src, size_t n) {
|
|
|
|
char * out = dest;
|
|
|
|
while (n > 0) {
|
|
|
|
if (!*src) break;
|
|
|
|
*out = *src;
|
|
|
|
++out;
|
|
|
|
++src;
|
|
|
|
--n;
|
|
|
|
}
|
2018-11-27 12:41:50 +03:00
|
|
|
for (int i = 0; i < (int)n; ++i) {
|
|
|
|
*out = '\0';
|
|
|
|
++out;
|
|
|
|
}
|
2018-06-25 10:28:13 +03:00
|
|
|
return out;
|
|
|
|
}
|