I am just starting to learn C and I don't know how to get the compiled program to stay on the screen? When i hit run, it flashes really quick
C programming?
In The End Of Your Code - Add:
getch();
with this , compiler will stay for your input .
Reply:Well if you use getch(); you will need the header file conio.h. getch() is not ANSI compliant so i would not recommend you use it. A loop is a good idea or use this at the end of your program
fflush(stdin); //This empty's the buffer
getc(stdin); //Waits for the enter key to be pressed Report It
Reply:if you are using c++ using the header file iostream.h you can use
cin.get();
Reply:Put a timer or loop, or ask before it exit.
Reply:If you are running in a development platform, you can set a debugging breakpoint on your final return statement. When the program gets there, it will stop until you restart it.
Reply:I'm assuming you're running a console.
So, chances are very good you have no pauses in your program, it is compiling, running, displaying text, and exitting.
Try adding a line (without quotes).
"pause();"
Reply:If it is a console program, use kbhit() to wait for a keypress.
petunia
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment