1234567891011121314151617181920212223242526272829303132
#include <stdio.h> #undef strncpy char *STRNCPY(char *dest, const char *src, int n) { char c; char *s = (char*)src; do { c = *s++ *++dest = c; if (--n == 0) return dest; } while (c != 0); do { *s++ = 0; --n; } while (n > 0); return dest; }
c = *s++ ;