For Programmers: Free Programming Magazines  


Home > Archive > C > June 2006 > Re: How to prevent the quick disappearance of window









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: How to prevent the quick disappearance of window
Robert Gamble

2006-06-28, 3:56 am

Jordan Abel wrote:
> Richard Bos <rlb@hoekstra-uitgeverij.nl> wrote:
>
> OT: one such appropriate windows-specific function is system("pause").
>
> or you could just do
> puts("");
> puts("Press enter to continue...");
> getchar();
> return 0;


It's worth noting that simply calling getchar() will leave all
characters except the first one on the input stream if the user entered
any before pressing the "return" key which may not be desirable. In
such a case something like "while(getchar() != '\n')" may be preferred.

Robert Gamble

av

2006-06-28, 6:56 pm

On 27 Jun 2006 22:59:51 -0700, "Robert Gamble" <rgamble99@gmail.com>
wrote:

>Jordan Abel wrote:
>
>It's worth noting that simply calling getchar() will leave all
>characters except the first one on the input stream if the user entered
>any before pressing the "return" key which may not be desirable. In
>such a case something like "while(getchar() != '\n')" may be preferred.
>
>Robert Gamble


int c;

while( (c=getchar())!= '\n' && c!=EOF);

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com