part 1
#include <iostream>
using namespace std;
int main(){
int *pOne = new int(1);
delete pOne;
int *pTwo = new int(2);
*pOne = 100;
cout<<"one:"<<*pOne<<endl;
cout<<"two:"<<*pTwo<<endl;
return 0;
}
one:100
two:100
part 2
char *p = (char *) malloc(100);
strcpy(p, “hello”);
free(p); // p 所指的内存被释放,但是p所指的地址仍然不变
if(p != NULL) // 没有起到防错作用
{
strcpy(p, “world”); // 出错
}