For Loop Exit Condition (size_t vs. int) [duplicate]
问题 This question already has answers here : What's the best way to do a reverse 'for' loop with an unsigned index? (20 answers) Closed 5 years ago . When I put the following in my program: for (size_t i = VectorOfStructs.size()-1; i > 0; i--) It works correctly but does "i" will never equal 0. So, I cannot access the first element (VectorOfStructs[0]). If I change it to: for (size_t i = VectorOfStructs.size()-1; i > -1; i--) The program doesn't even enter the for loop! But, if I change it to the