P不会是NULL
int main()
{
if (p == NULL)
{
cout<<"P is NULL"<<endl;
}
else
{
cout<<"error "<<endl; //这步将被执行
}
return 0;
}
int main()
{
int *p;//p 默认指向oxcccccccc
p = (int *)malloc(0);//P指向ox003960co , 效果同p = (int *)malloc(1)
if (p == NULL)
{
cout<<"P is NULL"<<endl;
}
else
{
cout<<"error "<<endl; //这步将被执行
}
return 0;
}