Reading Input from a file, line-by-line
For an assignment in my C course, I need to write a program that reads lines of numbers from a file, sorts them, writes the output to a file then reads the next line and continues, until a -1 is reached in the file.
My question is: how would I go about doing this? Or, rather, which functions should I use to read the file as such. The pseudocode for what I want to do is:
Read (Line until end of line is reached)
Convert each number read into int, then put it into a 1-dimensional array
Do the sorting ('Pancake sorting', if you want to know)
Write the output to a file.
Read in the next line and repeat the sequence.
I'm not exactly sure how to read the file and pick out the numbers from a string, and, moreso, how to make it start reading from a specific line in the file.
(Note: Not asking for you to write the program for me, I'm just asking for help filling in the metaphorical blanks.)