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????

Recommended Answers

All 2 Replies

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.

It could be your text file. Towards the end, you might have empty lines
in your file. Check it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.