![]() -> Click here to learn how to get live help <- |
STRDUPIndexNAMEstrdup, strndup, strdupa, strndupa - duplicate a stringSYNOPSIS#include <string.h> char *strdup(const char *s); #define _GNU_SOURCE DESCRIPTIONThe fBstrdup()fP function returns a pointer to a new string which is a duplicate of the string fIsfP. Memory for the new string is obtained with fBmallocfP(3), and can be freed with fBfreefP(3).The fBstrndup()fP function is similar, but only copies at most fInfP characters. If fIsfP is longer than fInfP, only fInfP characters are copied, and a terminating NUL is added. fBstrdupafP and fBstrndupafP are similar, but use fBalloca(3)fP to allocate the buffer. They are only available when using the GNU GCC suite, and suffer from the same limitations described in fBalloca(3)fP. RETURN VALUEThe fBstrdup()fP function returns a pointer to the duplicated string, or NULL if insufficient memory was available.ERRORS
CONFORMING TOSVID 3, BSD 4.3. fBstrndup()fP, fBstrdupa()fP, and fBstrndupa()fP are GNU extensions.SEE ALSOalloca(3), calloc(3), free(3), malloc(3), realloc(3)
Index |