So I'm trying to loop and read in values from my csv while there are values to be read. What do I use for the while condition?

I tried all manner of things.....

void load()
{//read from file
	ifstream inFile("csv.txt");
	string line;
	
	if(inFile.is_open())
	{
	}
	else
	{
		cout << "Error opening file!" << endl;
	}
	
	while()
		{
			aircraft temp;
			stringstream stream(line);
			stream >> temp.serial;
			stream.ignore ( std::numeric_limits<std::streamsize>::max(), ',' );
			getline(stream,temp.name,',');
			stream.ignore ( std::numeric_limits<std::streamsize>::max(), ',' );
			getline(stream,temp.manufacturer, ',');
			stream >> temp.registration;
			stream.ignore ( std::numeric_limits<std::streamsize>::max(), ',' );
			getline(stream,temp.owner, ',');
			getline(stream,temp.productionDate, ',');
			getline(stream,temp.stdInspection, ',');
			getline(stream,temp.extraInspection, ',');
			mainList.push_front(temp);						
		}
		
		inFile.close();
	
}

use

while(!inFile.fail()){...}

use

while(!inFile.fail()){...}

Loop does not exit :S

what do you mean by loop dies not exist? if you put !inFile.fail() inside your while it doesn't work?

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.