Your question shows that you do not understand buffers. Since that is what your assignment is apparently about you should probably have learned about it, unless you're confused about having to use "open" and "read" instead of the more usual "fopen" and "fread" (or fgets or fscanf), which handle the buffer for you.
The code you've given is not even close to what you'd need. What I would do in this situation is make my own function similar to fgets, but that takes a file descriptor instead of a FILE* (and will either need to be passed "buffer" and "buffer_pos" variables (or a struct) or have them as static locals). This is not too difficult, but not entirely trivial either since lines will occasionally span buffer boundaries. With such a function, I would write my main program to read the file line-by-line, and use sscanf (if you're allowed to!?) to extract the data from each line.
As for "how can the buffer end at any point", suppose the buffer were 10 chars long and you read a file containing the chars "hello world\n":
Code:
0123456789
hello worl
Notice that the d and newline won't fit. The buffer doesn't know anything about end of lines, it's just a fixed chunk of bytes. The next buffer-full of the file will have to be read before the line can be completed. So we'd copy what we have so far in the buffer to our line string, read the next buffer:
Code:
0 123456789
d\n........
and add up to the newline to the end of the line string.
BTW, a bandaid solution to your problem would be to make your buffer size bigger than your file size. But that's cheating if this assignment is all about implementing your own buffer handling.