]>
git.gag.com Git - fw/sdcc/blobdiff - device/lib/_strncpy.c
char *strncpy (
char * d,
char * s,
- int n )
+ size_t n )
{
register char * d1 = d;
- while ( n-- )
+ while ( n && *s )
+ {
+ n-- ;
*d++ = *s++ ;
+ }
+ while ( n-- )
+ {
+ *d++ = '\0' ;
+ }
return d1;
}