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

The Archive Base Latest Questions

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

I am confused about getchar() ‘s role in the following code. I mean I

  • 0

I am confused about getchar()‘s role in the following code. I mean I know it’s helping me see the output window which will only be closed when I press the Enter key.

So getchar() is basically waiting for me to press enter and then reads a single character.

What is that single character this function is reading? I did not press any key from the keyboard for it to read.

Now when it’s not reading anything, why does it not give an error saying “hey, you didn’t enter anything for me to read”?

#include <stdio.h>

int main()
{
    printf( "blah \n" );
    getchar();
    return 0;
}
  • 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-13T22:13:47+00:00Added an answer on May 13, 2026 at 10:13 pm

    The getchar() function will simply wait until it receives a character, holding the program up until it does.

    A character is sent when you hit the enter key; under a Windows OS, it will send a carriage return (CR) and a line-feed (LF).

    See this CodingHorror post for a nicely put explanation.

    (…the explanation of the CR+LF part, not the getchar() blocking part)

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

Sidebar

Related Questions

I am a little confused about Accept-Encoding . I have Web Service which would
I'm a little confused about the HTTP protocol, from what i know HTTP was
I am confused about why this code says JPEG files and PNG files are
I'm a bit confused about the right way to write a code. I read
I'm a little confused about the MVVM pattern which i'm combining with PRISM. In
I've always been confused about this one. Consider the following loops: int [] list
I'm confused about the scope of the lambda variable, take for instance the following
I am little confused about outoging traffic cost in GAE projects. see: https://developers.google.com/storage/docs/pricingandterms So,
I am confused about why python needs cursor object. I know jdbc and there
I'm a bit confused about the streams... which is which? Simply, which stream should

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.