I'm trying to make a basic set of programs where one program asks the user for a set of values which the program writes into a file and where the other program reads the values from the file and prints them to the screen. Here's my code:
The reading program is as follows:
When I run both programs, the first one successfully writes into "inventory.txt", but the read function duplicates whatever was the last set of values. It looks like this:
Please enter item data (part number, quantity, price): 3, 1, 3.0
Please enter item data (part number, quantity, price): 0
Below are the items in your inventory.
Part# Quantity Item Price
3 1 $ 3.00
3 1 $ 3.00
I believe the issue is with my while (feof(fp)==0) but I don't quite understand how feof works and I can't figure out how to replace it without using a "break;"
How can I fix this duplication issue?