I don’t know why the variables are stored unequally. In the main function, 20 was added to the amount of displacement, and in the rest of the functions, 8 were added to each variable…Is there a source that knows these things?
void adrs(int* a, int* b) {
cout << "a adrs: " << a << " poadda: " << &a << endl;
cout << "b adrs: " << b << " poaddb: " << &b << endl;
return;
}
void adr_ordr(int c, int d) {
c = 0;
d = 0;
int* i = &c;
int* j = &d;
cout << "c: " << &c << endl;
cout << "d: " << &d << endl;
cout << "i: " << &i << endl;
cout << "j: " << &j << endl;
return;
}
int main() {
int x = 0;
int y = 0;
cout << "x adrs: " << &x << endl;
cout << "y adrs: " << &y << endl;
adrs(&x, &y);
adr_ordr(x, y);
return 0;
}
New contributor
The Grid is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.