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 499595
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:00:05+00:00 2026-05-13T06:00:05+00:00

My program reads a list of integers from user input [ keyboard] and calculates

  • 0

My program reads a list of integers from user input [ keyboard] and calculates some statistics

The user enters ‘x’ to terminate the input process.

So for example,

Enter integers separated by space ( enter x to quit) : 1 2 3 4 5 x

But now I want to include the inputs to be read from file redirection also. So if the numbers followed by x is in a data file, the program should take it from there if not then prompt the user

  • 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-13T06:00:06+00:00Added an answer on May 13, 2026 at 6:00 am

    use isatty for your file descriptor
    (0 for standard input)

    example:

    #include <unistd.h>
    main(){
      if(isatty(0))
        puts("tty");  // print some prompt
      else
        puts("pipe"); // not really needed in your case
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My SSIS program reads as input from a .csv file. The file has about
I have a program that reads input from a file. I am trying to
I have a program which reads commands from a text file for example, the
I'm writing a program that reads from a list of files. The each file
I am building a program which reads text files, containing a list of numbers.
Below is the program that I wrote. /******************************************************************************* * This program reads EOF from
I have a program that reads data from a file line-by-line. I would like
I need a program that reads from multiple files and displays a report based
I have a program which reads Inbox messages from email accounts, as the title
My program reads in files from a given directory on program start (each one

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.