vector<int> score= {1,1,1,1,1};
int z = score.size();
for(int j=score.size() - 1; j >= z - 5; --j)
cout << j << endl;
The code right now is fine but causes an error when I replace that line with:
for(int j=score.size() - 1; j >= score.size() - 5; --j)
From the print out, I've deducted it's because j goes to -1 and beyond. My question is why is this happening when I just substituted z for the size() function? The inside of the for loop does not modify size[i].