October 26th, 2012, 10:26 AM
[C] parsing EOF
Someone came to me for help with a task. THat someone takes part in a very basic C course, and this is only their 1st day. The task left me clueless, anyways...
Note that the required language is not c++, but c; however, i hope someone can help me out anyways...
Here`s the text:
you`re then supposed to convert the numbers to integers and do some calculations.
YOu have to expect the following input:
an arbitrary amount of lines, each line consists of 5 int32 numbers. The full input will be terminated by an EOF.
1 2 3 4 5
6 7 8 9 0
i would know how to parse a single line of 5 numbers via scanf(). That`s easy, and that`s exactly what they did in class.
But how do i go about splitting the lines? What about the EOF?
Even if could hack something together, by using errno or something, it would be way beyond what they are doing atm.
the input is received via user input, ie stdin.
is there any easy way i missed?
Last edited by tuli; October 26th, 2012 at 10:42 AM.
October 26th, 2012, 11:26 AM
Click Here to Expand Forum to Full Width