xref: /plan9/sys/src/ape/lib/ap/gen/strncpy.c (revision 3e12c5d1bb89fc02707907988834ef147769ddaf)
1 #include <string.h>
2 
3 char*
strncpy(char * s1,const char * s2,size_t n)4 strncpy(char *s1, const char *s2, size_t n)
5 {
6 	int i;
7 	char *os1;
8 
9 	os1 = s1;
10 	for(i = 0; i < n; i++)
11 		if((*s1++ = *s2++) == 0) {
12 			while(++i < n)
13 				*s1++ = 0;
14 			return os1;
15 		}
16 	return os1;
17 }
18