char *strncpy(char *dest, const char *source, size_t n) {
char *start = dest;
while (n && (*dest++ = *source++)) n--;
// I don't understand from the code below this
// I know I put'\0' at the end of dest.
// But I don't know how if (n) while (--n) works.
if (n) while (--n) *dest++ = '\0';
return start;
}
http://www.jbox.dk/sanos/source/lib/string.c.html#:38
Aucun commentaire:
Enregistrer un commentaire