Get address of an int variable : int pointer « Data Types « C++ Tutorial






#include <iostream> 
using namespace std; 
 
int main() 
{ 
  int total; 
  int *ptr; 
  int val; 
 
  total = 3200; // assign 3,200 to total 
 
  ptr = &total; // get address of total 
 
  val = *ptr;   // get value at that addres  
 
  cout << "Total is: " << val << '\n'; 
 
  return 0; 
}
Total is: 3200








2.3.int pointer
2.3.1.Using int pointers
2.3.2.Get address of an int variable
2.3.3.Calculation based on pointer