I have some difficulty in working with files in C. I already know how to read and write files in C but all I can do is just read and append. If I want to read lines of strings and converting them to numbers (int
), how would I do it?
for example:
mytextfile.txt contains these data:
12345 30 15
2111 9 20
321 17 7
now for each line, I want to use the first number as a variable for price and the next number as quantity and the last number as discount. My problem is how am I going to store the three number on a variable so that I can use them as integers (or string)?
My output should have been the computed amount based on the price, quantity and discount listed down one value(the result) per line...