Address of operator and addresses of local variables : address of « Pointer « C++ Tutorial






#include <iostream>
 
 int main()
 {
     unsigned short shortVar=5;
     unsigned long  longVar= 5;
     long sVar = -5;
 
     std::cout << "shortVar:\t" << shortVar;
     std::cout << "\tAddress of shortVar:\t" << &shortVar << "\n";
     std::cout << "longVar:\t"  << longVar;
     std::cout << "\tAddress of longVar:\t"  << &longVar  << "\n";
     std::cout << "sVar:\t\t"   << sVar;
     std::cout << "\tAddress of sVar:\t"     << &sVar     << "\n";
 
     return 0;
 }
shortVar:       5       Address of shortVar:    0x22ff76
longVar:        5       Address of longVar:     0x22ff70
sVar:           -5      Address of sVar:        0x22ff6c








11.4.address of
11.4.1.Address of operator and addresses of local variables
11.4.2.Demonstrating the Address-of Operator
11.4.3.Printing the address stored in a char* variable