grubby破吹风流:mallco函数怎么用?

来源:百度文库 编辑:神马品牌网 时间:2024/04/27 20:26:40
如果我在输入的时候也不知道数组长度,怎么办?
还是不懂
怎么用的说

int nLen;
char * pBuffer=NULL;

nLen=500;

pBuffer=(char *)malloc(nLen+1);

sprintf(pBuffer,"dfjsldkfsdf");

free(pBuffer);
pBuffer=NULL;

那不用数组啊,用指针啊