A question on the number of lines

Write here if you have problems with your Pascal source code

Moderator: Board moderators

Post Reply
ggggqqqqihc
New poster
Posts: 12
Joined: Sun Dec 07, 2003 10:45 am

A question on the number of lines

Post by ggggqqqqihc » Sun Dec 07, 2003 11:00 am

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.

User avatar
sohel
Guru
Posts: 856
Joined: Thu Jan 30, 2003 5:50 am
Location: New York

Post by sohel » Sun Dec 07, 2003 11:54 am

in C,
you read until EOF, <end of file>

ggggqqqqihc
New poster
Posts: 12
Joined: Sun Dec 07, 2003 10:45 am

Post by ggggqqqqihc » Sun Dec 07, 2003 12:30 pm

Or simply stated. When I have inputted all the numbers, press ENTER twice, the program will stop. How can I do?

User avatar
sohel
Guru
Posts: 856
Joined: Thu Jan 30, 2003 5:50 am
Location: New York

Post by sohel » Sun Dec 07, 2003 12:40 pm

Read the input as string and if the lenght of it is zero it indicates the end of input.

ggggqqqqihc
New poster
Posts: 12
Joined: Sun Dec 07, 2003 10:45 am

Post by ggggqqqqihc » Sun Dec 07, 2003 12:45 pm

Good idea. Thanks. :lol:

Post Reply

Return to “Pascal”