Difference between revisions of "GDN:strdup"

From LibrePlanet
Jump to: navigation, search
 
Line 1: Line 1:
 
{{Infobox Function
 
{{Infobox Function
  
| header= [[<string.h>]]
+
| header= [[string.h]]
 
| since=  [[C90]]
 
| since=  [[C90]]
  
 
}}
 
}}
  
The strdup function copies the null-terminated string <code>s</code> into a newly allocated string. The string is allocated using <code>[[malloc]]</code> If <code>malloc</code> cannot allocate space for the new string, <code>strdup></code> returns a null pointer. Otherwise it returns a pointer to the new wide character string.
+
The strdup function copies the null-terminated string <code>s</code> into a newly allocated string. The string is allocated using <code>[[malloc]]</code> If <code>malloc</code> cannot allocate space for the new string, <code>strdup</code> returns a null pointer. Otherwise it returns a pointer to the new wide character string.
  
 
__TOC__
 
__TOC__

Latest revision as of 14:49, 19 December 2013


The strdup function copies the null-terminated string s into a newly allocated string. The string is allocated using malloc If malloc cannot allocate space for the new string, strdup returns a null pointer. Otherwise it returns a pointer to the new wide character string.

Contents

Prototype

<source lang="c">char * strdup (const char *s)</source>

GDN:strdup
Header string.h
Supported Since C90