strncpy.c - scc - simple c99 compiler
 (HTM) git clone git://git.simple-cc.org/scc
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) Submodules
 (DIR) README
 (DIR) LICENSE
       ---
       strncpy.c (220B)
       ---
            1 #include <string.h>
            2 
            3 #undef strncpy
            4 
            5 char *
            6 strncpy(char *restrict s1, const char *restrict s2, size_t n)
            7 {
            8         char *ret = s1;
            9 
           10         for (; n > 0 && *s2; --n)
           11                 *s1++ = *s2++;
           12 
           13         while (n-- > 0)
           14                 *s1++ = '\0';
           15 
           16         return ret;
           17 }