This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Problem with getchar method!


"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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]