Wednesday, December 29, 2010

C++ Static Pointers

An example of how pointers work on static variables


#include

using namespace std;

int main()
{

int *ptr;
int x = 64;

//& is the memory address of the variable
ptr = &x;
cout << "ptr = " << ptr << endl;
cout << "x= " << x << endl;
cout << "&x = " << &x << endl;
cout << "*ptr = " << *ptr << endl;


return 0;
}

No comments:

Post a Comment