First page Back Continue Last page Summary Graphics
Strncpy() and strncat()
Still requires extra attention
- strncpy() leaves dest unterminated if
- sizeof(dest) <= len(src)
- Usually followed by forcing a null char in the last character byte.
- char dest[MAXLEN];
-
strncpy(dest,src,MAXLEN);
dest[MAXLEN - 1] = '\0';
Slower
- strncpy() zero-fills remainder of dest
- Typical usage: large dest, small src