home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
vol_100
/
163_02
/
strncpy.c
< prev
next >
Wrap
Text File
|
1988-01-31
|
512b
|
12 lines
/*
** copy s2 to s1, truncating or null padding as necessary to create a string
** n characters long
*/
strncpy(s1, s2, n) char *s1, *s2; int n; {
char *strncpy;
strncpy = s1;
while(n--) if(!(*s1++ = *s2++)) break;
while(n-- > 0) *s1++ = 0;
return strncpy;
}