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

有帮助吗?

解决方案

int i;

int *p;

p=&i;

now *p will give you the content in that address.

其他提示

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++.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top