Obtaining an variables memory address – C++

What it does:
To obtain the variables address in memory simply place an ampersands in front of the variable. This will then return a hex number.


#include <iostream>
using namespace std;

int main()
{
       int numberOfChickens = 532587;
       cout << &numberOfChickens << endl;

       return 0;
}//main


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s