.\" Copyright (c) 1990, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" %sccs.include.redist.man% .\" .\" @(#)strdup.3 8.1 (Berkeley) 06/09/93 .\" .Dd .Dt STRDUP 3 .Os .Sh NAME .Nm strdup .Nd save a copy of a string .Sh SYNOPSIS .Fd #include .Ft char * .Fn strdup "const char *str" .Sh DESCRIPTION The .Fn strdup function allocates sufficient memory for a copy of the string .Fa str , does the copy, and returns a pointer to it. The pointer may subsequently be used as an argument to the function .Xr free 3 . .Pp If insufficient memory is available, NULL is returned. .Sh SEE ALSO .Xr malloc 3 .Xr free 3 .Sh HISTORY The .Fn strdup function first appeared in 4.4BSD.