Computer General/C++ development from the beginning
Address Operator & Pointer
so8991
2014. 12. 12. 19:26
Address Operator : it shows where in the memory the variable is stored
#include <iostream>
int main()
{
using namespace std;
int f = 10; //make variables
int e = 2;
//output on the screen?
cout<< f << endl;
cout<< &f <<endl; //address where the variable is located in the memory(HexDecimal location)
cout<< e <<endl;
cout << &e <<endl;
system("pause");
return 0;
}
===> useful for pointer
Pointer : variable that holds an address of your memory
int main()
{
int f = 10;
int e = 2;
//pointer and stored var should have same type
int *pointer; //what address??
//have to answer it..
pointer = $f;
cout<<pointer<<endl; //address of memory(point the space of your memory where the f is..)
return 0;
}