Category : C Source Code
Archive   : ECSTR.ZIP
Filename : STRNCPY.C

 
Output of file : STRNCPY.C contained in archive : ECSTR.ZIP
/* File : strncpy.c
Author : Richard A. O'Keefe.
Updated: 20 April 1984
Defines: strncpy()

strncpy(dst, src, n) copies up to n characters of src to dst. It
will pad dst on the right with NUL or truncate it as necessary to
ensure that n characters exactly are transferred. It returns the
old value of dst as strcpy does.
*/

#include "strings.h"

char *strncpy(dst, src, n)
register char *dst, *src;
register int n;
{
char *save;

for (save = dst; --n >= 0; ) {
if (!(*dst++ = *src++)) {
while (--n >= 0) *dst++ = NUL;
return save;
}
}
return save;
}



  3 Responses to “Category : C Source Code
Archive   : ECSTR.ZIP
Filename : STRNCPY.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/