http://baike.baidu.com.cn/view/1028541.htm
strdup
原型:extern char *strdup(char *s);头文件:#include <string.h>
用法:char *strdup(char *s);
功能:复制字符串s
说明:strdup()在内部调用了malloc()为变量分配内存,不需要使用返回的字符串时,需要用free()释放相应的内存空间,否则会造成内存泄漏
举例:
// strdup.c
//#include <syslib.h>
#include <stdio.h>
#include <string.h>
int main()
{
char *s="Golden Global View";
char *d;
clrscr();
d=strdup(s);
printf("%s",d);
free(d);
getchar();
return 0;
}