Page 1 of 1

A question on the number of lines

Posted: Sun Dec 07, 2003 11:00 am
by ggggqqqqihc
For example
Input:
Each line has two integral numbers, and there are some lines, but I don't know the number of lines. When the program has read the last line, I want it to stop. How can I do that?
I'm a beginner. Thanks.

Posted: Sun Dec 07, 2003 11:54 am
by sohel
in C,
you read until EOF, <end of file>

Posted: Sun Dec 07, 2003 12:30 pm
by ggggqqqqihc
Or simply stated. When I have inputted all the numbers, press ENTER twice, the program will stop. How can I do?

Posted: Sun Dec 07, 2003 12:40 pm
by sohel
Read the input as string and if the lenght of it is zero it indicates the end of input.

Posted: Sun Dec 07, 2003 12:45 pm
by ggggqqqqihc
Good idea. Thanks. :lol: