Debug assertion failed

Why do i keep getting that error? Every time I run my program, it runs for a while and then it just crash and display the message Debug assertion failed. Any idea on how can i fix that?

Please I really need to fix my program, Tomorrow's the due date.
See where the program is when it is crashes and inspect the data values with a debugger.
Can you help me? Here's the code :
and it said "Expression: Vector subscript out of range"
Did you try breaking the program at that point to see what line it was on when it crashed?
Your problem is on lines 132 - 134, in this while loop:

 while(randomAnswer.size() < 4)//Then randomly gets 3 other answers from questionList
        	int randomindex = rand() % questionList.size() - 1;
         	if(randomindex != i){

I'm not going to try and understand exactly what is going on, but the problem is that at around the third iteration, randomindex is equal to -1 because of the previous operation, but it's also not equal to i. You then use it as an index for the questionList on the line that follows.
Last edited on
Thanks guys! I remove the -1 because as said the value of i becomes negative :)
Topic archived. No new replies allowed.