这个程序什么意思 求指导

[复制链接]
查看11 | 回复1 | 2010-6-28 22:29:35 | 显示全部楼层 |阅读模式
#include
#include
int main(void)
{

/*********Found************/

char pch[2];

/*********Found************/

if (pch = (char *)malloc(100) == NULL)

{

printf("malloc memory fail!\n");

return 1;

}

printf("%p\n", pch);

/*********Found************/

close(pch);
return 0;
}
程序的功能是申请100个字节的内存空间,显示其首地址,然后释放申请到的内存空间。以下是我改的
#include
#include
int main(void)
{

/*********Found************/

char pch[100];

/*********Found************/

if ((pch = (char *)malloc(100)) == NULL)

{

printf("malloc memory fail!\n");

return 1;

}

printf("%p\n", pch);

/*********Found************/

fclose(pch);
return 0;
}

回复

使用道具 举报

千问 | 2010-6-28 22:29:35 | 显示全部楼层
#include#includeint main(void){
/*********Found************/
char *pch = NULL;
/*********Found************/
if ((pch = (char *)malloc(100)) == NULL)
{
printf("malloc memory fail!\n");
return 1;
}
else
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行