I am a beginner to C and this is the dumbest question..Confused about getchar() function

Posted by happysoul on Stack Overflow See other posts from Stack Overflow or by happysoul
Published on 2010-03-09T10:08:18Z Indexed on 2010/03/09 10:21 UTC
Read the original article Hit count: 718

Filed under:
|
|

Sorry if I am not supposed to post beginner level questions here..I am new to this site

Please read the code below first

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

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

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

Now when its not reading anything..why it does not give an error saying hey u didn't enter anything for me to read ..lol...(told u its a dumb question)

#include <stdio.h>

int main()
{
printf( "blah \n" );
getchar();
return 0;
}

© Stack Overflow or respective owner

Related posts about c

    Related posts about getchar