| | |
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 1: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 9: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 8: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 11:43 am.
![]() |
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)
Views: 2439 | Replies: 17
| Thread Tools | Search this Thread |
Tag cloud for C
api array arrays binary binarysearch bit build c++ c/c++ calling char character code coke command conversion convert copy database decimal directory dude dynamic ebook error exec factorial fflush fgets file floatingpointvalidation fork function functions getline givemetehcodez grade graphics haiku help|help|help|help homework i/o include input insert int integer intmain() keyboard lazy libcurl line linked linkedlist linux list lists loop malloc matrix memory mysql no-effort output overwrite parallel path permutations pointer pointers problem process program programming read readfile recursion recursive recv reverse scanf socketprograming sockets spoonfeeding stdin string strings strtok structures student system testing turbo-c turboc unix user variable win32 windows _getdelim






