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...
fscanffunction doesn't work for you? What else have you tried? Please read about how to ask good questions, and learn how to create a Minimal, Complete, and Verifiable Example.sscanf(linebuf, "%d%d%d", &price, &quantity, &discount);to get the numbers.