Advertisement
vaibhav1906

Pointers

Nov 16th, 2021
1,046
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.43 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. int main(){
  4.    
  5.     int a = 5;
  6.    
  7.     cout<<"value is = "<<a<<endl;
  8.     cout<<"Address of a is = "<<&a<<endl;
  9.     cout<<"Value of a is = "<<*(&a)<<endl;
  10.    
  11.     int b = 10; // b is an integer means &b is address of b
  12.    
  13.     int *c = &b;  // *c as a whole is an integer means c is some address of *c
  14.     //c = &b;
  15.    
  16.     cout<<"b = "<<b<<endl;
  17.     cout<<"*c = "<<*c<<endl;
  18.    
  19.     b = 6;
  20.    
  21.     cout<<"*c = "<<*c<<endl;
  22.    
  23.    
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement