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\n",d);
free(d);
}
getchar();
return 0;
}
运行结果:
Golden Global View
②.Example:
CString sPath="d:\\1.jpg";
LPTSTR str = strdup( sPath );
posted @ 2015-04-08 01:27  vigorpush  阅读(115)  评论(0编辑  收藏  举报