Debug assertion failed. C++ vector subscript out of range
Regardless of how do you index the pushbacks your vector contains 10 elements indexed from 0 (0, 1, …, 9). So in your second loop v[j] is invalid, when j is 10. This will fix the error: In general it’s better to think about indexes as 0 based, so I suggest you change also your first loop to this: Also, to access the elements of a … Read more