Question
Can someone tell me why I am getting a infinite loop when this runs? I am trying to read in from a text file. void
Can someone tell me why I am getting a infinite loop when this runs?
I am trying to read in from a text file.
void readInventory(vector &list)
{
int i = 0;
string temp;
ifstream iFile("cars.txt");
iFile.open("cars.txt");
if (iFile.is_open());
{
while (!iFile.eof())
{
{
for (i = 0; i <= 100; i++)
{
iFile >> temp;
cout << "VIN:";
cout << temp << endl;
iFile >> temp;
cout << "Make:";
cout << temp << endl;
iFile >> temp;
cout << "Model:";
cout << temp << endl;
iFile >> temp;
cout << "Year:";
cout << temp << endl;
iFile >> temp;
cout << "Price:";
cout << temp << endl;
iFile >> temp;
}
}
}
}
iFile.close();
cout << endl;
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started