I need help with pointers | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
0

I need help with pointers

So we know that an array is actually a pointer, BUT when I cout the array say it is arr[] when I cout arr the memory location CHANGES EVERY SINGLE TIME like how....it is supposed to be a pointer to the first element in the array which is the address I see when I print arr. So how come does the address of the first element changes rapidly fast as if it is riding a motorcycle inside the memory 😂.

21st Mar 2024, 7:25 AM
Intermediate Depression
Intermediate Depression - avatar
1 ответ
+ 1
Intermediate Depression it might change everytime you rerun the program, but what is important is it stays the same while it is running. int arr[]{2,2,3,4}; cout<<&arr<<endl; arr[0] = 200; cout<<&arr<<endl; arr[0] = 43; cout<<&arr<<endl;
21st Mar 2024, 10:28 AM
Bob_Li
Bob_Li - avatar