C code example for strdup

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <malloc.h>
int main()
{
char *s="Golden Global View";
char *d;
clrscr();
d=strdup(s);
if(NULL != d) {
printf("%s ",d);
free(d);
}
getchar();
return 0;
}
运行结果:
Golden Global View
②.Example:
CString sPath="d:\1.jpg";
LPTSTR str = strdup( sPath );
原文地址:https://www.cnblogs.com/vigorz/p/10499133.html