Output pointer value using cout : long « Data Types « C++ Tutorial






#include <iostream>
using std::cout;
using std::endl;

int main() {
  long* pnumber;                        
  long number1 = 55L;
  long number2 = 99L;                   

  pnumber = &number1;                   
  *pnumber += 11;                       
  cout << endl
       << "number1 = "     << number1
       << "   &number1 = " << pnumber
       << endl;

  pnumber = &number2;                   
  number1 = *pnumber * 10;              

  cout << "number1 = "     << number1
       << "   pnumber = "  << pnumber
       << "   *pnumber = " << *pnumber
       << endl;

  return 0;
}
number1 = 66   &number1 = 0x22ff70
number1 = 990   pnumber = 0x22ff6c   *pnumber = 99








2.12.long
2.12.1.pointer to long value
2.12.2.Use long as function parameter and return type
2.12.3.Cast int to long
2.12.4.Output pointer value using cout