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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T02:54:03+00:00 2026-06-10T02:54:03+00:00

I am a complete beginner in C programming, so please have some patience with

  • 0

I am a complete beginner in C programming, so please have some patience with me. I am trying to input a file name from the user in the console and I want to print a helpful message that prompts the user to enter the filename he wants to open. But when I run this in the command prompt, the cursor waits for the input first and after I enter some text and hit Return, I see the helpful prompt that I wanted to print before the input. Here is the code snippet.

 char filename[40];
 fputs("enter the file name: ", stdout);
 fflush(stdout); 
 fgets(filename, sizeof(filename), stdin);

I can’t see where I am going wrong with this. I would really appreciate if some one could explain why this happens.

  • 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-06-10T02:54:04+00:00Added an answer on June 10, 2026 at 2:54 am

    I do not see any issues with the code you have pasted, works fine with gcc. It must be something to do with the stdout not being flushed, which could be specific to the compiler you are using…

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

Sidebar

Related Questions

I am a complete beginner here. Can someone please post some Delphi code to
I am a complete, total beginner in programming, although I do have knowledge of
Complete programming beginner just trying to clarify something, I was creating keys for a
I'm a complete beginner in JS, so pls have patience :) my.hello = function
I'm almost a complete beginner at programming (only did some basic a long time
As a complete beginner with no programming experience, I am trying to find beautiful
I'm a complete beginner with Code::Blocks and SQLite, and have some basic knowledge with
please note that I'm a complete beginner to Qt development. I have a QWebView
I am a complete beginner trying to develop for FCKeditor so please bear with
Note: Near complete beginner to logic programming I need to compare two lists of

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.