Help me with file

Hello,
I dont print of code:
I want print of last line until the third line of file, look my code:

historico.txt:
Sum: 3 4 5 6 = 18
Sum: 2 3 4 5 = 32
Sum: 3 4 5 6 = 50
Sum: 1 2 3 4 = 60
Sum: 5 6 7 = 78
Sum: 3 3 5 6 = 17
Sum: 2 2 = 4


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>
#include <fstream>

using namespace std;

int main()
{
    int cont = 3;
    string operacao;
    ifstream input("historico.txt");

    for(int j = input.eof(); j >= 3; j--){
        operacao = "";
        while(input >> operacao && input.peek() != '\n'){
            cout << operacao << " ";
        }
        cout << operacao << endl;
    }
    return 0;
}
Last edited on
Topic archived. No new replies allowed.