Need help reading text file

So this program records your inputed stats after a game, it saves them to a textfile everytime you input them. However near the end I am having trouble with making the program read the textfile once the user inputs "yes" to the answer
"Do you wish to view your previous score?"
I wonder if its a small fix or a complete re-write of that section :D
Thanks ahead

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
  #include <iostream>
#include <string>
#include <fstream>
#include <Windows.h>
using namespace std;

int main()
{
    double kills;
    double deaths;
    double kdratio;
    double rounds;
    double killsperround;
    double deathsperround;
    string mapname;


    HANDLE h = GetStdHandle( STD_OUTPUT_HANDLE );
    SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_INTENSITY);

    cout << "How many rounds did you play this game? (Please enter correct number to work out Kills/Deaths per round" << endl;
    cin >> rounds;
    cout << "You played " << rounds << " rounds" << endl;

    cout << "Please enter the amount of kills you got this game " << endl;
    cin >> kills;
    cout << "You got " << kills << " kills" << endl;

    cout << "Please enter how many times you died this game " << endl;
    cin >> deaths;
    cout << "You died " << deaths << " times" << endl;

        kdratio = kills / deaths;

    cout << "Your KD Ratio for this game is " << kdratio << endl;

    cout << "Please enter the map you have played" << endl;
    cin >> mapname;
    cout << "You played " << mapname << endl;

    killsperround = kills / rounds;
    deathsperround = deaths / rounds;

    cout << "You got " << kills << " kills and " << deaths << " deaths, you played on " << mapname << " and got a KD Ratio of " << kdratio << endl;
    ofstream scores;
    cout << "Your Kills per round were " << killsperround << " and your deaths per round were " << deathsperround << endl;
    if(kdratio>1){
            HANDLE h = GetStdHandle( STD_OUTPUT_HANDLE );
            SetConsoleTextAttribute(h, FOREGROUND_GREEN | FOREGROUND_INTENSITY);
        cout << "Your KDA was greater than 1 this game, congratulations! Keep it up" << endl;
        }else{
            HANDLE h = GetStdHandle( STD_OUTPUT_HANDLE );
            SetConsoleTextAttribute(h, FOREGROUND_RED | FOREGROUND_INTENSITY);
            cout << "Your KDA was less than 1, better luck next time!" << endl;
            }
    HANDLE g = GetStdHandle( STD_OUTPUT_HANDLE );
    SetConsoleTextAttribute(g, FOREGROUND_BLUE | FOREGROUND_INTENSITY);
    scores.open("scoresandmap.txt", ios::app);
    scores << "You got " << kills << " kills and " << deaths << " deaths you played on " << mapname << " and got a KD Ratio of " << kdratio << endl;
    scores << "Your Kills per round were " << killsperround << " and your deaths per round were " << deathsperround << endl;
    scores.close();

    string answer;
    cout << "Do you wish to view your previous scores? (Yes/No)" << endl;
    cin >> answer;
    if(answer == "yes"){
        ifstream inFile;
        inFile.open("scoresandmap.txt");

        //Check for Error
        if (inFile.fail()) {
            cerr << "Error finding text file" << endl;
            exit(1);
        }
    }else{
    exit(1);}


    }
Topic archived. No new replies allowed.