The Single UNIX ® Specification, Version 2
Copyright © 1997 The Open Group

 NAME

strdup - duplicate a string

 SYNOPSIS



#include <string.h>

char *strdup(const char *s1);

 DESCRIPTION

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

 RETURN VALUE

The strdup() function returns a pointer to a new string on success. Otherwise it returns a null pointer and sets errno to indicate the error.

 ERRORS

The strdup() function may fail if:
[ENOMEM]
Storage space available is insufficient.

 EXAMPLES

None.

 APPLICATION USAGE

None.

 FUTURE DIRECTIONS

None.

 SEE ALSO

malloc(), free(), <string.h>.

UNIX ® is a registered Trademark of The Open Group.
Copyright © 1997 The Open Group
[ Main Index | XSH | XCU | XBD | XCURSES | XNS ]