Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

strncpy() vs strncat()

Name: Anonymous 2008-07-05 17:26

Hey /prog/, I've just googled this and it returned a bunch of faggots complaining about buffer overflows.

My question is, as both functions seem to do the same thing, which one would you use?

The man page doesn't leave this clear either, it just says that strcpy zerofills the buffer.

Name: man 2008-07-06 5:38

The stpcpy() and strcpy() functions copy the string s2 to s1 (including the terminating `\0' character).

The strcat() and strncat() functions append a copy of the null-terminated string s2 to the end of the null-terminated string s1, then add a terminating `\0'.  The string s1 must have sufficient space to hold the result.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List