Need help in skipping a line of text from a file when using a loop

Thanks for the help!
Last edited on
The easiest way is to read and ignore the isbn - as you do.
Another - more complicated option - is to read the line via getline, use string.find to find the first space and then use a stringstream after you used string.substring to get price and coverstyle.

Some other points:
You need to initialize your variables before you use them, otherwise the have random starting values and your calculations will be wrong.
Before the for loop you read one line already why?
In your for loop you use the number 20. Why not using numOfBooks ?
Hello casey250,

Thomas1965 has made some good points that should be addressed especially the first one.

After you open the file, which you should check to see if it opened, you read four pieces of information, but the last three are never processed in any way which throws the for loop off by one.

As I have worked with your program the for loop is only reading the second line of the file and nothing else. I have not figured out why yet.

The other part I noticed, if the program worked, is that you process the file, but never display any results. And I also noticed that "isbn" as an "int" will drop any leading zeros in the number.

Hope that helps,

Andy
Again, OP deletes original post after getting help thereby ensuring nobody can use this thread in future.
Topic archived. No new replies allowed.