-
help with arrays in C++
Code:
const int SIZE = 10;
int a[SIZE] = {1,2,3,4,5,6,7,8,9,10};
int *p;
int i;
p = a+(SIZE/2);
cout << p << endl;
for(i = 0; i < SIZE/2; i++)
{
cout << (p+i) << " = " << *(p+i) << " "
<< (p-(i+1)) << " = " << *(p-(i+1))
<< endl;
}
who can explain this coding to me
how i assume the starting Aray a is 0012FF30
-
You can't assume the array starts anywhere.
You could try outputting a+i rather than p+i
All it is doing is outputting the addresses and contents of various elements of the array.