C++ examples for Data Type:Pointer
Demonstrates the use of pointer declarations and operators.
#include <iostream> using namespace std; void main()/*from w w w .j av a 2 s . co m*/ { int num=123; // A regular integer variable. int *p_num; // Declares an integer pointer. cout << "num is " << num << "\n"; // Prints value of num. cout << "The address of num is " << &num << "\n";// Prints num's location. p_num = # // Puts address of num in p_num, in effect making p_num pointto num. No * in front of p_num. cout << "*p_num is " << *p_num << "\n"; // Prints value of num. cout << "p_num is " << p_num << "\n"; // Prints location of num. return; }