Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7081535
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:55:59+00:00 2026-05-28T06:55:59+00:00

I need to implement in C the program ,which reads an unknown number of

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T06:56:00+00:00Added an answer on May 28, 2026 at 6:56 am

    This depends on when you want your program to stop. There are several common approaches:

    1. Never: you run an infinite loop until end-user hits ^C or otherwise terminates your program using the facilities of your operating system
    2. Until the user enters a special marker, i.e. a “keyword” QUIT, EXIT, etc. on a line by itself
    3. Until the user enters an empty line (i.e. hits Enter)

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a program that reads in from a serial port, then
I'm writing a program which will need to do a very large number of
I want to implement program by c# application. first of all I need web
I need to read from a dataset which is very large, highly interlinked, the
I am doing a program in which i need to insert enum values into
is it possible to convert a Python program to C/C++? I need to implement
I have a program that accepts input from the command line. While all of
i need to implement a program to count the occurrence of a substring in
I need to implement a Diff algorithm in VB.NET to find the changes between
I need to implement version control, even for just the developing I do at

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.