*

Board index » C Language

All times space UTC




You are watching: C++ press enter to continue

Press enter to Continue
I am finishing a C program, at the end of a while loop i prompt user to "Press enter to continue" (this is a requirement), the when loop need to do one more itteration after ~ I press Enter. I cannot obtain it to iterate again after pressing enter. I have been do the efforts to usage a scanf through a dummy variable but no luck . ??
Sun, 04 may 2003 15:58:22 GMT
Press enter to Continue
> ns am finishing a C program, in ~ the finish of a when loop ns prompt user to > "Press go into to continue" (this is a requirement), the while loop should do > another itteration ~ I push Enter. I cannot gain it come iterate again > after pressing enter. I have actually been make the efforts to use a scanf v a fake > variable but no happy . ??
Sun, 04 may 2003 03:00:00 GMT
>> ns am finishing a C program, at the end of a while loop ns prompt user to >> "Press enter to continue" (this is a requirement), the while loop must do >> an additional itteration after ~ I press Enter. I cannot acquire it to iterate again >> after pressing enter. I have actually been do the efforts to usage a scanf v a fake >> variable but no luck . ?? > shot > c=getch(); > if(c==13) /* User pressed go into */ > ....
No, don"t. That"s MS-DOS-specific. Try: while (getchar()!=" "); the still has actually some bugs, ie. The user is can not to signal the finish of input, yet anyway my version is far better than the one above. code example: #include int main(void) { if (1) printf("La di da, I"m act an iteration... "); printf("Press get in to continue "); while (getchar()!=" "); return 0; /* not actually needed, due to the fact that execution never gets here */
-- | Kingpriest that "The paris Lemon Tree" G++ FR FW+ M- #80 D+ ADA N+++ | | http://www.helsinki.fi/~palaste W++ B OP+ | ----------------------------------------- Finland rules! ------------/ "A bicycle cannot stand up by itself due to the fact that it"s two-tyred." - sky Text
> > ns am finishing a C program, at the end of a when loop i prompt user to > > "Press enter to continue" (this is a requirement), the when loop should do > > an additional itteration ~ I press Enter. I cannot acquire it come iterate again > > after pressing enter. I have actually been trying to use a scanf through a fake > > variable yet no luck . ?? > shot > c=getch(); > if(c==13) /* User pressed go into */ > .... > Greetings, Urs
Not in ISO C. getc(stdin) or getchar() will do the task as the OP explcitely asks the user come press get in (not any type of key) sort regards Robert -- i don"t do my mistakes an ext than once. I save them carefully and also after some time i take them the end again, add some brand-new features and _reuse_ them.
> >> ns am finishing a C program, in ~ the end of a when loop ns prompt user to > >> "Press get in to continue" (this is a requirement), the when loop should do > >> one more itteration after ~ I push Enter. Ns cannot get it to iterate again > >> after pressing enter. I have been do the efforts to usage a scanf with a dummy > >> variable but no luck . ?? > > try > > c=getch(); > > if(c==13) /* User pressed enter */ > > .... > No, don"t. That"s MS-DOS-specific.
Or curses, yet differently, for this reason this will certainly break. Which, the course, is _why_ it is important not to confuse ISO C with "whatever my compiler supports". Richard
>I to be finishing a C program, in ~ the end of a if loop ns prompt user to >"Press go into to continue" (this is a requirement), the while loop must do >another itteration after ~ I press Enter. I cannot gain it to iterate again >after pressing enter. I have been do the efforts to use a scanf through a dummy >variable however no happy . ??
>I am finishing a C program, at the end of a if loop i prompt user come >"Press enter to continue" (this is a requirement), the if loop have to do >another itteration ~ I push Enter. Ns cannot obtain it come iterate again >after pressing enter. I have actually been do the efforts to usage a scanf with a fake >variable but no happy . ??
First, be certain there"s nothing left in stdin"s buffer (e.g. By a ahead scanf call). Then, you can do the following: scanf("%*<^ >"), scanf("%*c"); The an initial scanf call will discard any type of characters coming before the enter key, if the user pressed some various other keys before Enter. The 2nd scanf speak to will certainly discard the Enter vital itself. of course, assuming the user hasn"t redirected stdin. Otherwise, over there is no typical C equipment to your difficulty (but there space platform particular solutions). Dan -- Dan popular music CERN, IT division Mail: CERN - IT, Bat. 31 1-014, CH-1211 Geneve 23, Switzerland
>> ns am finishing a C program, in ~ the end of a if loop i prompt user to >> "Press get in to continue" (this is a requirement), the while loop must do >> an additional itteration ~ I press Enter. Ns cannot gain it to iterate again >> after pushing enter. I have been do the efforts to usage a scanf v a fake >> variable however no luck . ?? >Try >c=getch();
I acquired a linker failure as soon as I do the efforts this. Then after I discovered a library the has getch, namely -lcurses, the regimen crashed! Hmm, undefined habits have the right to do things choose that! check out the FAQ.


See more: Rohnert Park Post Office Hours, Usps Post Office Rohnert Park

There is no need in the C language the an Enter key on the interaction input an equipment produces character password 13. On every UNIX systems, because that instance, the produces a newline " " (because the terminal driver is always, by default, in the ICRNL mode).
1. Push Any key To Continue...

2. Getchar(); (Press a key to continue)

3. Press any crucial to continue

4. Push any an essential to continue...

5. "Press any vital to continue"

6. Push Any key to Continue

7. Exactly how to simulate a computer mouse press?..continued

8. CListBox (Extended style) - spoofing VK_CONTROL push to continue an option and other woes