Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- int main()
- {
- int name=5;
- int *ptr_name=&name;
- cout<<"address of name:"<<&name<<endl;
- cout<<"&ptr_name:\t"<<&ptr_name<<endl;
- cout<<"pr_name:\t"<<ptr_name<<endl;
- cout<<"*ptr_name:\t"<<*ptr_name<<endl;
- int other=10;
- ptr_name=&other;
- cout<<"\n\n***point to other\n";
- cout<<"address of name:"<<&name<<endl;
- cout<<"address of other:"<<&other<<endl;
- cout<<"&ptr_name:\t"<<&ptr_name<<endl;
- cout<<"pr_name:\t"<<ptr_name<<endl;
- cout<<"*ptr_name:\t"<<*ptr_name<<endl;
- other=5;
- cout<<"\n\n***other=5\n";
- cout<<"value of other:\t"<<other<<endl;
- cout<<"*ptr_name:\t"<<*ptr_name<<endl;
- *ptr_name=100;
- cout<<"\n\n*** *ptr_name=100\n";
- cout<<"value of other:\t"<<other<<endl;
- cout<<"*ptr_name:\t"<<*ptr_name<<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement