GLProgramming.com

home :: about :: development guides :: irc :: forums :: search :: paste :: links :: contribute :: code dump

-> Click here to learn how to get live help <-


Manpage of STRDUP

STRDUP

Index
 

NAME

strdup, strndup, strdupa, strndupa - duplicate a string  

SYNOPSIS

#include <string.h>

char *strdup(const char *s);

#define _GNU_SOURCE

#include <string.h> char *strndup(const char *s, size_t n);
char *strdupa(const char *s);
char *strndupa(const char *s, size_t n);
 

DESCRIPTION

The 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 VALUE

The fBstrdup()fP function returns a pointer to the duplicated string, or NULL if insufficient memory was available.  

ERRORS

ENOMEM
Insufficient memory available to allocate duplicate string.
 

CONFORMING TO

SVID 3, BSD 4.3. fBstrndup()fP, fBstrdupa()fP, and fBstrndupa()fP are GNU extensions.  

SEE ALSO

alloca(3), calloc(3), free(3), malloc(3), realloc(3)


 

Index

NAME
SYNOPSIS
DESCRIPTION
RETURN VALUE
ERRORS
CONFORMING TO
SEE ALSO