Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

strdup - duplicate string

&pagelevel(4)&pagelevel

Syntax

#include <string.h>

char *strdup(const char *s1); 

Description

strdup() returns a pointer to a new string, which is a duplicate of the string pointed to by
s1. The space for the new string is allocated using malloc(). The returned pointer can be
passed to the free() function. A null pointer is returned if the new string cannot be created.

Return val.

Pointer to the new string

 



if successful.

 

Null pointer

if an error occurs. errno is set to indicate the error.

Errors

strdup() will fail if: 


ENOMEM

There is not enough memory.

See also

malloc(), free(), string.h