| | |
Stupid Question
Thread Solved |
•
•
Join Date: Nov 2006
Posts: 22
Reputation:
Solved Threads: 0
I start C tomorrow and reading my book. When I run and compile this code it comes up in DOS and runs the code but then the DOS window closes. I'm new with C, can someone tell me why the DOS window flashes and then closes? Here's my code:
Thanks
C Syntax (Toggle Plain Text)
#include <stdio.h> int main( void ) { printf( "\t\"whoops\b\b\b\bew\n\"\n"); return 0; }
Thanks
It's for some reasons better to compile and run the programs using command line, but if you want to use ide, then you may write something like this in the end:
Notice that you cannot use any other single character than newline for that, when you use only standard c, because in standard c the standard input is line buffered.
C Syntax (Toggle Plain Text)
printf ("== press enter ==\n"); getchar ();
Last edited by TkTkorrovi; Aug 28th, 2007 at 2:23 pm.
Knowledge is regarded by the fool as ignorance, and the things that are profitable are to him hurtful. He liveth in death. -- Thoth the Atlantean
•
•
Join Date: Nov 2006
Posts: 22
Reputation:
Solved Threads: 0
•
•
•
•
It's for some reasons better to compile and run the programs using command line, but if you want to use ide, then you may write something like this in the end:
Notice that you cannot use any other single character than newline for that, when you use only standard c, because in standard c the standard input is line buffered.C Syntax (Toggle Plain Text)
printf ("== press enter ==\n"); getchar ();
This would be better
c Syntax (Toggle Plain Text)
printf("Hit 'ENTER' to exit\n"); fflush(stdout); (void)getchar();
Last edited by SpS; Aug 28th, 2007 at 10:50 pm.
•
•
•
•
This would be better
c Syntax (Toggle Plain Text)
printf("Hit 'ENTER' to exit\n"); fflush(stdout); (void)getchar();
Last edited by hollystyles; Aug 29th, 2007 at 9:29 am.
Since some compilers (and lint) will warn about discarded return values, an explicit cast to (void) is a way of saying "Yes, I've decided to ignore the return value from this call.
Last edited by SpS; Aug 29th, 2007 at 12:43 pm.
![]() |
Similar Threads
- Probably a stupid question but... (Windows NT / 2000 / XP)
- n00b question linked to bits :rolleyes: (Assembly)
- Stupid question about java.exe (Java)
- I know I'll sound stupid but... (Geeks' Lounge)
- a stupid question!!! (Windows Software)
- Another photoshop question! (Graphics and Multimedia)
- This may be a stupid question.... (C++)
- Stupid Newbie Question (C)
- Ive got a question that needsa answerin. (Search Engine Optimization)
Other Threads in the C Forum
- Previous Thread: Dll
- Next Thread: Scanning (with TWAIN)
| Thread Tools | Search this Thread |
#include adobe api array arrays asterisks binarysearch calculate char cm copyanyfile copyimagefile copypdffile cprogramme creafecopyofanytypeoffileinc createcopyoffile 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 linked linkedlist linux linuxsegmentationfault list lists locate logical_drives loopinsideloop. match matrix meter microsoft motherboard mqqueue mysql number odf open opensource owf pattern pdf performance pointer posix probleminc process program programming pyramidusingturboccodes radix read recursion recv repetition research scanf scheduling scripting segmentationfault send sequential shape socket socketprograming stack standard string systemcall turboc unix user voidmain() wab win32api windows.h






