Hi so I am trying to open this file in my program, but I keep getting a few errors along with this function.. wondering what is wrong with it?
these are the errors:
error C2228: left of '.open' must have class/struct/union
error C2065: 'infile' : undeclared identifier
error C2228: left of '.eof' must have class/struct/union
Thank you in advance for taking a look at it!
1 2 3 4 5 6 7 8 9 10 11 12 13
void ReadData(string item[], int qty[], string location[], int price[], int NumProducts)
{
infile.open("products.txt");
while(!infile.eof())
{
getline(infile, item[NumProducts]);
getline(infile, qty[NumProducts]);
getline(infile, location[NumProducts]);
getline(infile, price[NumProducts]);
}
infile.close();
}