Why is my code starting at line 10?

When the following program is run, function only starts at line 10. It might help to just compile it in case I'm not being clear on what I mean.
breakfasts.txt is below the program.

Edit: my compiler is stupid, it only displays the last couple of lines.

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
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>

using namespace std;

int main()
{
    ifstream inFile;
    cout << fixed << showpoint << setprecision(2);
    
    inFile.open("breakfasts.txt");

    if(!inFile)
    { cout << "Cannot open the input file. Program Terminates!" << endl; return 1; }
    
    string line[16];
    //if statement evaluates odd/even, if odd j++, if even, k++
    for(int i = 0; i < 16; i++)
    {
        getline(inFile,line[i]);
        cout << "Line " << i << ":  " << line[i] << endl;
    }
    
    return 0;
}


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Plain Egg
1.45
Bacon and Egg
2.45
Muffin
0.99
French Toast
1.99
Fruit Basket
2.49
Cereal
0.69
Coffee
0.50
Tea
0.75
Last edited on
Line 0:  Plain Egg
Line 1:  1.45
Line 2:  Bacon and Egg
Line 3:  2.45
Line 4:  Muffin
Line 5:  0.99
Line 6:  French Toast
Line 7:  1.99
Line 8:  Fruit Basket
Line 9:  2.49
Line 10:  Cereal
Line 11:  0.69
Line 12:  Coffee
Line 13:  0.50
Line 14:  Tea
Line 15:  0.75


what are you talking about?
My compiler only displayed the last few lines for some reason.
Hello Tduck,

The compiler only compiles the program. The only output it has is what it did and any error messages it has.

Did You mean when the program runs?

If you could show what you are talking about it would help.

When I ran the program it worked fine with this output:

Line 0:  Plain Egg
Line 1:  1.45
Line 2:  Bacon and Egg
Line 3:  2.45
Line 4:  Muffin
Line 5:  0.99
Line 6:  French Toast
Line 7:  1.99
Line 8:  Fruit Basket
Line 9:  2.49
Line 10:  Cereal
Line 11:  0.69
Line 12:  Coffee
Line 13:  0.50
Line 14:  Tea
Line 15:  0.75



Do not confuse what the compiler does with what happens when the program is run.

Hope that helps,

Andy
Edit: my compiler is stupid, it only displays the last couple of lines.

No, not the compiler. An IDE perhaps? Something that has compiler, editor and console "integrated".

Sure, one can have a "window" that shows only N last lines of output, but that would be odd.
Perhaps the "window" can be resized?
Perhaps it has longer buffer and you can "scroll" backwards to earlier lines.

If neither, then use an another.


Even the cmd.exe "console" has "buffer" and "height"; how many lines are kept in memory and how many lines of buffer are visible, respectively.
It was a mix of the fact that I was using a chromebook, no mouse, and the fact that the scrollbar was completely invisible and arrow keys wouldn't work to scroll.

Translation: I couldn't scroll up and I had no idea that was an option so I thought it was a bug.
Topic archived. No new replies allowed.