|
Last change
on this file since c79db87 was 3ae31e9, checked in by Thomas Lopatic <thomas@…>, 8 years ago |
|
Imported original source code.
|
-
Property mode
set to
100755
|
|
File size:
533 bytes
|
| Line | |
|---|
| 1 | /*
|
|---|
| 2 | =============================================================================
|
|---|
| 3 | strncpy.c -- copy string of n bytes
|
|---|
| 4 | Version 1 -- 1987-06-12
|
|---|
| 5 |
|
|---|
| 6 | Copy s2 to s1, truncating or null-padding to always copy n bytes
|
|---|
| 7 | return s1
|
|---|
| 8 | =============================================================================
|
|---|
| 9 | */
|
|---|
| 10 |
|
|---|
| 11 | char *
|
|---|
| 12 | strncpy(s1, s2, n)
|
|---|
| 13 | register char *s1, *s2;
|
|---|
| 14 | register int n;
|
|---|
| 15 | {
|
|---|
| 16 | register char *os1 = s1;
|
|---|
| 17 |
|
|---|
| 18 | while (--n >= 0)
|
|---|
| 19 | if ((*s1++ = *s2++) == '\0')
|
|---|
| 20 | while (--n >= 0)
|
|---|
| 21 | *s1++ = '\0';
|
|---|
| 22 |
|
|---|
| 23 | return (os1);
|
|---|
| 24 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.