Problem z wyłączaniem się programu

0

Witam, napisałem program w C++. Wszystko powinno działać a o dziwo wysypuje się na 41 linijce. Macie jakieś sugestie?

#include <iostream>
#include <fstream>
#include <cstdlib>
#include <algorithm>
#include <string>
using namespace std;
int main()
{
    string Q[5];
    string A[5],B[5],C[5],D[5];
    string CA[5];
    fstream f1;
    string l;
    string topic,author;
    string answer;
    int nr_l=1;
    int nr_q=0;
    int points=0;
    f1.open("Quiz.txt",ios::in);
    if(f1.good()==false)
    {
        cout<<"The file does not exist"<<endl;
        exit(0);
    }
    while(getline(f1,l))
    {
        switch(nr_l)
        {
            case 1: topic=l;            break;
            case 2: author=l;          break;
            case 3: Q[nr_q]=l;        break;
            case 4: A[nr_q]=l;        break;
            case 5: B[nr_q]=l;        break;
            case 6: C[nr_q]=l;        break;
            case 7: D[nr_q]=l;        break;
            case 8: CA[nr_q]=l;      break;
        }
        if(nr_l==8)
        {
            nr_l=2;
            nr_q++;
        }
        nr_l++;
    }
    f1.close();
    cout<<"The topic of the quiz is: "<<topic<<endl;
    cout<<"The author of a quiz is: "<<author<<"\n\n"<<endl;
    for(int i=0;i<=4;i++)
    {
        cout<<Q[i]<<endl;
        cout<<"A. "<<A[i]<<endl;
        cout<<"B. "<<B[i]<<endl;
        cout<<"C. "<<C[i]<<endl;
        cout<<"D. "<<D[i]<<endl;
        cout<<"Your Answer is: ";
        cin>>answer;
        transform(answer.begin(),answer.end(),answer.begin(), ::tolower);
        if(answer==CA[i])
        {
            cout<<"\n"<<"Correct answer.You earned 1 point."<<endl;
            points++;
        }
        else cout<<"Wrong answer.The correct answer is "<<CA[i]<<endl;
    }
    cout<<"A quiz has been finished. You earned "<<points<<" Congratulations!"<<endl;
    return 0;
}
3

https://www.cs.cmu.edu/~gilpin/tutorial/
https://lldb.llvm.org/tutorial.html
https://blogs.msdn.microsoft.com/vcblog/2017/06/23/c-tutorial-debugging-overview/

Wybierz sobie

PS nikt nie będzie sobie tutaj liczył linijek. Podaj treść błędu oraz wskaż miejsce gdzie to się dzieje.

1 użytkowników online, w tym zalogowanych: 0, gości: 1