code help

I need to read data from a file and I know im missing a while loop. the name of the file is "books.dat"

I need to take this:

fp>> books;
fp>> shipping;

for (int i=1; i <= books; i++)
{
fp>>prices;
sum+=prices;
}

and have it nested on a while loop.
1
2
3
4
5
for (int i=1; i <= books && fp; i++)
{
fp>>prices;
sum+=prices;
}
Topic archived. No new replies allowed.