64,642
社区成员
发帖
与我相关
我的任务
分享
//编译器是Dev-C++
...
int main(){
int myint = 5;
int *ptr1 = &myint;
cout<<"*ptr1 = "<<*ptr1<<endl;
int anotherint = 6;
int *ptr2;
cout<<"*ptr2 = "<<*ptr2<<endl;
*ptr2 = anotherint; //+
int yetanotherint = 7;
int *ptr3;
ptr3 = &yetanotherint;
cout<<"*ptr3 = "<<*ptr3<<endl;
*ptr1 = *ptr2; //危险的赋值
cout<<"*ptr1 = "<<*ptr1<<endl;
}