سؤال

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