Pointers C | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Pointers C

void test(int k); int main() { int i = 0; printf("The address of i is %x\n", &i); test(i); printf("The address of i is %x\n", &i); test(i); return 0; } void test(int k) { printf("The address of k is %x\n", &k); } Why does it give a different adress when "i" is accessed through the function test and ehen through printf?

23rd Apr 2019, 3:47 PM
Ana T
1 Answer
0
Because i and k are different variables, therefore they allocate in memory on different places hence have different addresses
23rd Apr 2019, 6:09 PM
Vadim Brovenko
Vadim Brovenko - avatar