I am currently trying to make a learning Ai from scratch to familiarize myself with how it all works (project code is linked here My current issue is finding a way to stop the while loop on line 20 once the eof has been reached. I have tried using fin.eof, the output I get when I use this is "Segmentation fault (core dumped)". how can I get the code to run properly?
Here is my code:
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
using namespace std;
struct Match{
    vector<int> sitVal;
    vector<int> opVal1;
    vector<int> opVal2;
    vector<int> opVal3;
};
//fills chosen Match with data from file
void conData(string file, Match& sits){
    ifstream fin;
    fin.open(file);
    int jump;
    fin >> jump;
    int i = 0;
    while(true){
        fin >> sits.sitVal[i];
        if (!fin)
            break;
        fin >> sits.opVal1[i];
        fin >> sits.opVal2[i];
        fin >> sits.opVal3[i];
        i++;
    }
    //following is for testing
    cout << sits.sitVal[0];
    cout << sits.opVal1[0];
    cout << sits.opVal2[0];
    cout << sits.opVal3[0];
}
int main(){
    Match sits;
    conData("Data.txt", sits);
}
 
     
    