void main() { char *p = NULL; if((p = new char[10]) !=NULL) { strcpy(p, "hello"); cout<<p<<endl; delete []p;// p 所指的内存被释放,但是p 所指的地址仍然不变 p = NULL;//防止变成野指针 } if(p != NULL) { strcpy(p, "world"); cout<<p<<endl; } }