"Zuan Chen" <cy*********@163.com> wrote in message
news:m3************@localhost.localdomain...
A program should read a series of inputs from console, but the number of
series is not pre-determined.
Sample input:
1 2
3 4
100 200
500 600
...
The Input may terminated by "\n\n".
I want to use scanf() function to read the input, but I cannot write the
right code.
Probably because scanf() is not the right tool for the job (or at least,
it's not the obvious tool for the job to me).
I would use fgets() in a loop. You can check if an empty line was entered,
and terminate the loop if so. Otherwise you pass the line to sscanf() in
order to extract the numbers (or whatever), do any processing that is
required, then loop back to call fgets() again.
Alex