home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Atari Compendium
/
The Atari Compendium (Toad Computers) (1994).iso
/
files
/
prgtools
/
mint
/
network
/
lattice
/
netlib.lzh
/
MINTNET.LIB
/
LIB
/
SNCPY.C
< prev
next >
Encoding:
Amiga
Atari
Commodore
DOS
FM Towns/JPY
Macintosh
Macintosh JP
Macintosh to JP
NeXTSTEP
RISC OS/Acorn
Shift JIS
UTF-8
Wrap
C/C++ Source or Header
|
1994-12-27
|
445 b
|
24 lines
/*
* Almost like strncpy() except that it returns the length
* of the copied string, terminates dst always with exectly
* one '\0'.
*/
#include <stdio.h> /* for size_t */
int
_sncpy (dst, src, len)
char *src, *dst;
size_t len;
{
int count = len;
if (count <= 0) return 0;
while (--count >= 0 && (*dst++ = *src++) != 0);
if (count < 0) {
dst[-1] = '\0';
return (len - 1);
}
return (len - count - 1);
}