I am practicing for a c++ midterm, and I can’t see why the following code is incorrect.
int ip[] = {6, 7, 2, 4, -5};
for (int i = 0; i < 5; ++i, ++ip)
cout << *ip;
My suspicion is that is it something to do with the -5, but I’m lost, and I’d really like to get this resolved.
You cannot increase
ip, since it is an array, and not a pointer – so its value [ip] is fixed.So, the problem is with the expression
++ip