|
|
1.1 root 1: /*
2: * strncpy.c
3: * ANSI 4.11.2.4.
4: * Copy one fixed length string to another.
5: */
6:
7: #include <string.h>
8:
9: char *strncpy(s1, s2, n) char *s1; char *s2; size_t n;
10: {
11: register char *cp;
12:
13: for (cp = s1; n; ) {
14: n--;
15: if ((*cp++ = *s2++) == '\0')
16: break;
17: }
18: /* Pad remainder of s1 with NUL if required. */
19: while (n-- > 0)
20: *cp++ = '\0';
21: return (s1);
22: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.