For the most part you have it correct. You're going to have a change a few things around.
This is the only part that needs fixing:
Code:
while(!outfile.eof())
{outfile >> cust[ i ].fname;
outfile >> cust[ i ].lname;
outfile >> cust[ i ].acct;
outfile >> cust[ i ].amt;
i++;
}
First off, you should not have a loop to check for the end of the file, because with fstream I don't think the file ever ends when you write to it, I think it just keeps expanding it. So just make it a for loop if you really need to increment the i variable.
Second off, your ">>" keyword is pointing the wrong way. It should be pointing outfile ("<<").
So here is what I would write the code to look like:
Code:
for(i=0;i<10;i++)
{outfile << cust[ i ].fname;
outfile << cust[ i ].lname;
outfile << cust[ i ].acct;
outfile << cust[ i ].amt;
i++;
}
Hope this helps