Hi, i have problem .I want to load infomrations abour person from text file. There is name, surname and some unlimited poin.We dont know how many points there is. i try to put this informations into vector<struct> person
struct{
string name
string surname
vector<double> points
}
than i want to load it from .txt but i have problem with this cause i dont know how many points there is. If i know for example, there is 4 points i use
struct{
string name
string surname
double point1
double point2
double point3
double point4
}
here is what i have for now. dont work>} please help, sorry for my english
#include "stdafx.h"
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <fstream>
using namespace std;
struct OSOBA {
string meno;
string priezvisko;
vector<double> body;
};
int _tmain(int argc, _TCHAR* argv[])
{
ifstream ifsSubor;
ifsSubor.open("vstup.txt");
string sRiadok;
vector<OSOBA> osoby;
double bod;
OSOBA o;
while(! ifsSubor.eof())
{
getline(ifsSubor,sRiadok);
istringstream istrRiadok(sRiadok);
istrRiadok>> o.meno;
istrRiadok>> o.priezvisko;
istrRiadok>> bod;
o.body.push_back(bod);
osoby.push_back(o);
int i=0;
vector<OSOBA>::iterator it;
for(it = osoby.begin(); it != osoby.end(); ++it)
{
cout.width(15);
cout <<left << (*it).priezvisko <<"\t" << (*it).meno<<"\t" << (*it).body<<endl;
}
return 0;
}
}