fmt_strn.c (227B)
1 #include "fmt.h" 2 3 unsigned int fmt_strn(char *s, char *t, unsigned int n) 4 { 5 unsigned int len; 6 char ch; 7 len = 0; 8 if (s) { while (n-- && (ch = t[len])) s[len++] = ch; } 9 else while (n-- && t[len]) len++; 10 return len; 11 }