Why is the nr variable in my code incremented way above 5?
When I test how many times the while loop iterates, it cycles way more times than there are elements in my data file, I cannot understand why.
The data file contains - a 1 2 3 b
Here's my code:
#include <fstream>
#include <iostream>
#include <string>
using namespace std;
struct SOMETHING 
{
    string string[10];
    int int_1[100];
};
void main() 
{
    int nr = 0;
    SOMETHING P;
    ifstream D("data.txt");
    while(!D.eof())
    {
        nr++;
        if (nr == 1 || nr % 5 == 0)
        {
            D >> P.string[nr]; 
            cout << P.string[nr] << " ";
        }
        D >> P.int_1[nr];
        cout << P.int_1[nr] << " ";
    }
    D.close();
} 
 
     
     
    