This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Problem with getchar method!
- From: Ian Lance Taylor <ian at airs dot com>
- To: "DC A" <adc4444 at hotmail dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: 22 Jul 2005 23:10:45 -0700
- Subject: Re: Problem with getchar method!
- References: <BAY106-F135C88054B17ABC1DA1337A9C80@phx.gbl>
"DC A" <adc4444@hotmail.com> writes:
> Hi! I'm completely new at gnu c and I 've a problem with getchar()
> method.
This mailing list is for the discussion of development of gcc. It is
not for C programming questions. Please find some other mailing
list. Thanks.
> My program is given below. first it asks for a number than it
> shows the squared output which begins from 1 to that number. But after
> 24 output it supposed to stop and show a message "Press enter to
> continue..." and when pressed return key it should proceed with the
> calculation. My program shows the squarred output fine but it doesn't
> stop after 24 And also I don't want to use scanf. Can anyone please
> tell me where i am doing wrong?
You have to press newline to pass the input line to scanf, but scanf
doesn't actually read the newline. It is not read until the getchar
later in the function.
Ian