作者在 2010-04-01 17:03:45 发布以下内容
void main(void){
char * pahcr=NULL;
pchar=(char *)malloc(1);
cout<<"申请的地址为:"<<pchar<<endl;
cout<<"请输入一个字符"<<endl;
scanf("%c",pchar);
cout<<"你输入的字符为"<<endl;
printf("%c\n",*pchar);
free(pchar);//执行该语句后发生错误为什么
pchar=NULL;
cout<<"释放掉指针后地址为"<<pchar<<endl;
cout<<"申请的地址为:"<<pchar<<endl;
cout<<"请输入一个字符"<<endl;
scanf("%c",pchar);
cout<<"你输入的字符为"<<endl;
printf("%c\n",*pchar);
free(pchar);//执行该语句后发生错误为什么
pchar=NULL;
cout<<"释放掉指针后地址为"<<pchar<<endl;
}