I am keep getting error on access violation. Program suddenly stops another code page appears. I do break. I am closing iosfwd file and then do continue. There is no actual error. I don't understand what is the problem. I am beginning of the code and I did this many times never get an error like that. I appreciate for help.
#include <iostream>
#include <fstream>
#include <string>
usingnamespace std;
//Creating class for the city
class City
{
public:
string name;
int numOfOutages;
int totalCust;
};
int main()
{
City data[41];
int count = 0;
//Reading from File
ifstream inFile("C:\\Users\\Ruk\\Documents\\IOFiles\\lipa.txt");
if (inFile.good())
{
while (!inFile.eof())
{
inFile >> data[count].name;
inFile >> data[count].numOfOutages;
inFile >> data[count].totalCust;
count++;
}
}
inFile.close();
system("PAUSE");
return 0;
}