How do I store my comma separated file in a vector structure, not a CSV text file?
I have a file called FILE.txt which has data like this
Date,ID,ArrivalTime,DepatureTime
12/02/2022,BDF 021,12:30:20,_
13/02/2022,FSD 213,10:20:30,12:30:20
etc. I have a vector called vector<vehicle> vehic(100);
.
I want to store it in the vector such that it will be the date will be stored, ID etc
Function for adding vehicles
I add vehicles using a function
void vehicle::addVehicle()
{
vehicle *v = new vehicle;
cin.ignore();
cout<<"Enter vehicle number : ";
std::getline(cin, v->id);
cout<<"Enter arrival time in hours minutes and seconds : ";
cin>>v->arrive.hh>>v->arrive.col1>>v->arrive.mm>>v->arrive.col2>>v->arrive.ss;
cout<<"Enter date in day month and year: ";
cin>>v->dt.day>>v->dt.sym1>>v->dt.month>>v->dt.sym2>>v->dt.year;
vehic.at(i).id=v->pltno;
vehic.at(i).arrive.hh=v->arrive.hh;
vehic.at(i).arrive.mm=v->arrive.mm;
vehic.at(i).arrive.ss=v->arrive.ss;
vehic.at(i).dt.day=v->dt.day;
vehic.at(i).dt.month=v->dt.month;
vehic.at(i).dt.year=v->dt.year;
}
I would like to store it in the same structure as I added them using this function. How would I do so?