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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:18:51+00:00 2026-06-11T09:18:51+00:00

In my simple program, when it executes the getchar method execute before printf method.

  • 0

In my simple program, when it executes the getchar method execute before printf method.
Why this happen and how to solve this??

#include <stdio.h>
#include <stdlib.h>

#define SUCCESS 0

void exit_Pro()
{
    printf("Press any Key to exit: ");
    fflush(stdin);
    getchar();
}
int main(int argc, char **argv) {
    atexit(exit_Pro);

    return SUCCESS;
}

Platform: Window 7
Compiler(IDE): Eclipse CDT

  • 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-11T09:18:52+00:00Added an answer on June 11, 2026 at 9:18 am

    First of all, I agree with nonsensical: fflush(stdin) is a bad thing to do. Here’s further explanation. (And if 9 experienced programmers all told me that I was doing something wrong, I’d believe them.)

    Now, to try and help you debug your code, can you tell us whether this simplified code exhibits the same problem on your system?

    #include <stdio.h>
    
    int main(int argc, char *argv[]) {
        printf("Press any Key to exit: ");
        fflush(stdout);
        getchar();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

// A simple program that computes the square root of a number #include <stdio.h>
This is a really simple program I'm writing here but came up to the
I'm trying to do a simple fork -> execute another program -> say hello
I've got a program that executes a method through a Thread.Start. The method has
I have one simple program that's using Qt Framework. It uses QProcess to execute
I've written a simple program that captures and executes command line Python scripts, but
I'm developing a simple program which makes a Python script executable, and I'm working
I have a simple program. I want to set the path and some properties
I'm writing a simple program to convert text to strings. One quick question, how
Possible Duplicate: A simple program to CRUD node and node values of xml file

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.