请输入您要查询的百科知识:

 

词条 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;

}

CString sPath="d:\\\\1.jpg";

LPTSTR str = strdup( sPath );

随便看

 

百科全书收录4421916条中文百科知识,基本涵盖了大多数领域的百科知识,是一部内容开放、自由的电子版百科全书。

 

Copyright © 2004-2023 Cnenc.net All Rights Reserved
更新时间:2025/3/1 20:39:19