strdup()

duplicate string 

Function


SYNOPSIS

#include <string.h>

char *strdup(const char *s1);


DESCRIPTION

The strdup() function allocates memory and copies into it the string addressed by s1, including the terminating null character. It is the user's responsibility to free the allocated storage by calling free().


PARAMETERS

s1 

Is a null-terminated string to duplicate.


RETURN VALUES

On success, strdup() returns a pointer to a newly allocated copy of the string s1. On failure, strdup() returns a null pointer and sets errno as follows:

ENOMEM 

Insufficient memory is available to copy the string s1.


CONFORMANCE

UNIX 98.


MULTITHREAD SAFETY LEVEL

MT-Safe.


PORTING ISSUES

None.


AVAILABILITY

PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition


SEE ALSO

Functions:
calloc(), free(), malloc(), strcpy()


PTC MKS Toolkit 9.6 patch 1 Documentation Build 5.