I was given some code by my Professor and I had to debug it. I finally found the problem, but I have no idea why it is a problem. Could someone please enlighten me.
Here is the piece of the code that has been corrected:
.
.
.
//Using negative subscripts
cout<<"\nUsing negative subscripts"<<endl;
p = a + n-1;
for (size_t i =0; i < n ; ++i)
cout << p[-i] << ' ';
cout<< endl;
Here is the original code piece with the error:
.
.
.
//Using negative subscripts
cout<<"\nUsing negative subscripts"<<endl;
p = a + n-1;
for (size_t i =0; i < n ; ++i)
cout << p[-i] << ' '; // <------ There is an extra space.
cout<< endl;
Why does it display what it does, instead of just add two spaces between each number? :-/