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

  • SEARCH
  • Home
  • 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 1046497
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:09:18+00:00 2026-05-16T16:09:18+00:00

I am working on a simple application written in C. I am working in

  • 0

I am working on a simple application written in C. I am working in a Unix environment.

My application is doing some simple I/O. I use printf to prompt the user for some input and then use scanf to get that input.

The problem is, I don’t know how to tell my application that I am ready to proceed after entering in a value. Typing ‘enter’ provides a newline ‘\n’ which makes sense. Control-d does allow scanf to capture my input but seems to ignore any subsequent scanf instructions.

Can someone help me out?

printf("Enter name\n");
scanf("%s",input);
printf("%s",input);

printf("enter more junk\n")
scanf("%s",morestuff); /* cntrl+d skips this*/
  • 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-16T16:09:19+00:00Added an answer on May 16, 2026 at 4:09 pm

    Check the return value from scanf(). Once it has gotten EOF (as a result of you typing control-D), it will fail each time until you clear the error.

    Be cautious about using scanf(); I find it too hard to use in the real world because it does not give me the control over error handling that I think I need. I recommend using fgets() or an equivalent to read lines of data, and then use sscanf() – a much more civilized function – to parse the data.

    See also a loosely related question: SO 3591642.

    • 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 GTK+ application written in python. I obviously use PyGtk.
I'm working on a simple application to start learning my way around WPF. I
I am working on a simple chat application using a System.Windows.Forms.WebBrowser Control to display
I'm working on a simple flex / AIR application with just a mx.TextInput control
I'm working on making a simple server application with python, and I'm trying to
I am working on an application which draws a simple dot grid. I would
I'm looking for good/working/simple to use PHP code for parsing raw email into parts.
i am working on a simple web app which has a user model and
I have written a simple test application using asp.net mvc with C#. The application
I'm currently working on an application written in C#, which I'm embedding IronPython in.

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.