0
void read (std::istream & _input) {
	string linijka;
	vector<string> entry;
	   string laaa, naa;
	int ii=0;


	while (getline(_input,linijka,'\n')) {
		
		cout<<"current line:"<<linijka<<endl;
	while(linijka[ii] != ',') {laaa+=linijka[ii]; ii++;}
	entry.push_back(laaa);
	ii++;
	 cout<<entry[0]<<endl;
	laaa.clear();
	while(linijka[ii] != '\n') {laaa+=linijka[ii]; ii++;}
	entry.push_back(laaa);
	   //doing something with entry 
	ii=0;
	laaa.clear();
	linijka.clear();
	entry.clear();
	
	}

	
	 }

my csv file is:

34,879
78,098

i use this file to initialize read function

and in console i have sthg like that:
current line:34,879
current line:78,098
current line:
current line:

why on the earth i have two extras lines?? despite thera are only two lines in a file and 'while' should be done only twice????

3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by firstPerson
0

one problem: move line 6 to line 9 because variable ii has to be reset to 0 on each loop iteration.

As for the problem you reported: I don't see where that code is displaying anything on the screen. The problem is more than likely in other parts of your program.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.