I'm a beginner in computer science learning c++.
Every attempt that I make to open a file in my program and read the information into a structure does not work.
Here is what I have written in the function.
void getMemberInfo(Payment member[])
{
ifstream file;
file.open("information.txt", ios::in);
int i = 0;
if (!file)
cout << "\n Error opening file!\n\n";
else
{
while (!file)
{
file >> member[i].ID;
file.getline(member[i].name, 30, '\n');
member[i].member_name = member[i].name;
file >> member[i].payment_due;
i++;
if (file.eof())
break;
}
}
file.close();
}
Any help is appreciated. I'm kind of at a loss of what's wrong.