uTools-Manuals/docs/c/strdup.html
2019-04-21 11:50:48 +08:00

36 lines
803 B
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<h1>字符串函数 - strdup</h1>
<p>原型extern char *strdup(char *s);</p>
<p>用法:#include &lt;string.h></p>
<p>功能复制字符串s</p>
<p>说明返回指向被复制的字符串的指针所需空间由malloc()分配且可以由free()释放。</p>
举例:<pre><code class="language-c">
// strdup.c
#include &lt;syslib.h>
#include &lt;string.h>
main()
{
char *s="Golden Global View";
char *d;
clrscr();
d=strdup(s);
printf("%s",d);
getchar();
return 0;
}
</code></pre>相关函数:<a href="memccpy.html">memccpy</a>,<a href="memcpy.html">memcpy</a>,<a href="strcpy.html">strcpy</a>