Question: how can I Use fscanf() inside a loop to read each line in C language? also how can I take the values from the file

how can I Use fscanf() inside a loop to read each line in C language?

also how can I take the values from the file and add them together for example if the file contents are

2

4

6

I want to read the first line and add 2 then the second one and add 4 and then the third and 6 and finally return the total 12 and stop reading.

I do not want to store the values in an array so I want to be able to deal with the data while I am reading each line.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!