while(!myfilename.eof()){
getline( myfilename , linelist );
linelist2 = linelist.substr(0,linelist.find(";")); //skips line after ';'
if(linelist2.find_first_not_of("#")){} //removes lines starts with #
else{
size_t pos = linelist2.find("=");
test = linelist2.substr(0,pos);
test2 = linelist2.substr(pos+1);
getlist.push_back(make_pair(test,test2));
}
}
//iterator
/*for(std::vector <std::pair<std::string,std::string>>::iterator it=getlist.begin(); it!=getlist.end();it++)
{
std::cout << it->first << "=>" << it->second << "\n";
}*/
myfilename.close();
I parsed the file and store in a vector. But my actual work is parse the file and store it in a class. for example:
class test{
string Name;
string address;
};
Now the text file can have
Name = tom
address = verger
how should i store it in a class members. Thats from vector to a class?
vector can have
Name=> tom
address=> verger