首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

malloc()的有关问题

2012-03-06 
malloc()的问题int main(){char *ptrif ((ptr (char *)malloc(0)) NULL)puts(Got a null pointer)

malloc()的问题
int main()
{

char *ptr; 
if ((ptr = (char *)malloc(0)) == NULL) 
puts("Got a null pointer"); 
else 
puts("Got a valid pointer"); 
free(ptr);
ptr = NULL;
return 0;
}

[解决办法]

探讨
指针没有申请到空间
free
产生错误。

热点排行