I have a code that reads a file with a following: word1,word2,word,3....,word8 word1,word2,word,3....,word8 word1,word2,word,3....,word8
ifstream infile;
//string path;s
infile.open("file.csv");
string line;
CourseNode *current = head;
int i=1;
if(infile.is_open()){
while(getline(infile, line)) {
if(i == 1)
cout << "1st line==> "+line << endl; // ignore first line
else { // read data
string firstname, lastname, id, a,b,c,d,t ;
stringstream sst(line);
getline(getline (sst, firstname, ','),lastname, ',');
//getline(getline(getline (sst, firstname, ','),lastname, ','),id, ',');
cout << "result==> "<< firstname<<" "<<lastname << endl;
}
i++;
}
I assume i have to work with this line and insert there my string variables but i am not sure how! getline(getline (sst, firstname, ','),lastname, ',');
Any help will be appreciateed! Thank you!
Aucun commentaire:
Enregistrer un commentaire