You can use the address-of operator & to get variable memory address.
#include <iostream> int main() /*from www . j a va2 s . c o m*/ { short shortVar = 5; long longVar = 65535; long sVar = -65535; 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; }