Reputation: 10153
I need to implement in C the program ,which reads an unknown number of lines from stdin.
I know that the maximum number of lines is 100.
I tried to use gets
,but I don`t know when to stop the loop.
Can you advise me how to implement it?
Upvotes: 2
Views: 482
Reputation: 726479
This depends on when you want your program to stop. There are several common approaches:
^C
or otherwise terminates your program using the facilities of your operating systemQUIT
, EXIT
, etc. on a line by itselfEnter
)Since the max number in your case is 100, you can use it as the limit to automatically terminate the input once the max is reached.
Upvotes: 1