| | |
How to make the output screen in C to stand for a long time.
![]() |
0
#2 29 Days Ago
If you are using turbo C then use getch() not getchar(). Its in the header file conio.h.
0
#3 29 Days Ago
The 3 Laws of the Procrastination Society:
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
0
#4 29 Days Ago
Thanks for the correction but may I know the hazards or any side-effect of using getch() it in TurboC.
Using getchar() we have to press the enter key but using getch() we can just press any key then why getchar() instead of getch().
Using getchar() we have to press the enter key but using getch() we can just press any key then why getchar() instead of getch().
Last edited by dkalita; 29 Days Ago at 3:52 am.
0
#5 29 Days Ago
•
•
•
•
when i press Ctrl+F9 , the output screen comes and goes without stopping for a while.
Please note that i have included "#include<stdio.h>" and i am using "getchar()" function do stop the screen.
C Syntax (Toggle Plain Text)
void PauseForUser(int promptUser, int clearStream) { if (clearStream) { int c; while ((c = getchar()) != '\n' && c != EOF) { /* all work in condition */ } clearerr(stdin); } if (promptUser) fputs("Press [Enter] to continue", stdout); getchar(); }
PauseForUser(1, 1); .•
•
•
•
may I know the hazards or any side-effect of using getch() it in TurboC.
•
•
•
•
Using getchar() we have to press the enter key but using getch() we can just press any key then why getchar() instead of getch().
-Tommy (For Great Justice!) Gunn
0
#6 29 Days Ago
•
•
•
•
In your code it might be called asC Syntax (Toggle Plain Text)
void PauseForUser(int promptUser, int clearStream) { if (clearStream) { int c; while ((c = getchar()) != '\n' && c != EOF) { /* all work in condition */ } clearerr(stdin); } if (promptUser) fputs("Press [Enter] to continue", stdout); getchar(); }PauseForUser(1, 1);.
clearerr(stdin); is necessary in this particular example? What risks I am not seeing when used without it? Thank you. 0
#7 29 Days Ago
•
•
•
•
May I impose on you by asking, why clearerr(stdin); is necessary in this particular example?
•
•
•
•
What risks I am not seeing when used without it?
In C89 I have not found an implementation that has the same behavior has C99, so it will probably work as intended without the call to clearerr(). But there is also no risk of not calling clearerr() in C89. It is better all around to assume the more strict rules of C99 and expect subsequent calls to an input function to fail after EOF or an error. That way your code works now and is future proofed. -Tommy (For Great Justice!) Gunn
1
#9 29 Days Ago
•
•
•
•
for windows getch and getchar can be used using the header file <conio.h>
In linux for the same you require <stdlib.h>
Last edited by Tom Gunn; 29 Days Ago at 12:55 pm.
-Tommy (For Great Justice!) Gunn
![]() |
Similar Threads
- Hyperlinks in Msn and Outlook express take a long time to open.. + More (Windows NT / 2000 / XP)
- CentOS 5.1 install on Dell D820 format of media bay drive takes unusually long time (*nix Software)
- Screen Output plus Logging in batch file (IT Professionals' Lounge)
- Long time to post/reply to threads (DaniWeb Community Feedback)
- Outlook express takes a long time to start up (Windows Software)
- IE takes a long time to get to new address (Web Browsers)
- Wowzas, been a long time! (Geeks' Lounge)
Other Threads in the C Forum
- Previous Thread: Structures And Unions
- Next Thread: Read Me : Always mark the thread solved when the problem is solved
| Thread Tools | Search this Thread |
#include adobe api array arrays asterisks binarysearch calculate char cm copyanyfile copyimagefile copypdffile cprogramme creafecopyofanytypeoffileinc createcopyoffile createprocess() csyntax database directory dynamic feet fflush fgets file fork forloop frequency getlasterror givemetehcodez global graphics gtkgcurlcompiling hacking hardware highest homework i/o include incrementoperators input interest kernel kilometer km linked linkedlist linux linuxsegmentationfault list locate logical_drives loopinsideloop. match matrix meter microsoft motherboard mqqueue mysql number odf open openwebfoundation owf pattern pdf performance pointer posix probleminc process program programming pyramidusingturboccodes radix read recursion recv repetition research scanf scheduling segmentationfault send sequential shape socket socketprograming stack standard string systemcall turboc unix user voidmain() wab win32api windows.h






