Poniższy kod może posłużyć jako punkt startowy…
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
struct Data {
double sl, sw, pl, pw;
string cl;
void print()
{
cout << sl << " " << sw << " " << pl << " " << pw << " " << cl << endl;
}
};
int main()
{
ifstream fin_train("c:\\temp\\iris\\iris_train.data");
if(!fin_train) cout << "ERROR" << endl;
vector<Data> d_train;
for(int i=0; i<120; ++i)
{
double sl, sw, pl, pw;
string cl;
char sep;
fin_train >> sl >> sep >> sw >> sep >> pl >> sep >> pw >> sep >> cl;
d_train.push_back({sl, sw, pl, pw, cl});
}
for(int i=0; i<120; ++i)
{
cout << i << ": ";
d_train[i].print();
}
}