Reputation: 3
If for example i have a variable i=1. How do i store its address using pointers? the user would input the address of the variable then the program would return the variable, for example: int i=1 address for example is 221122 then the user inputs 221122 and the value to be returned should be 1. c++ is the language
Upvotes: 0
Views: 89
Reputation: 111
int i;
int *p;
p=&i;
now *p will give you the content in that address.
Upvotes: 1
Reputation: 10894
Assuming you are using C or C++, you can Use the &
operator.
int num;
int* addrOfNum = #
This is a good tutorial about pointers, etc, in C++.
Upvotes: 1