I am a new user to Dev C++ and I was compiling and executing my programs and as soon as I put in the last input, my dos window gives an answer and closes automatically. How do you keep that window open?
Printable View
I am a new user to Dev C++ and I was compiling and executing my programs and as soon as I put in the last input, my dos window gives an answer and closes automatically. How do you keep that window open?
I never found a good way to do this.. :( but, i juse used a getch() to stop it at the end of execution :D
Use getch() before your main returns. I don't use DevC++ but from previous posts I understand that getch() will work with it. Just make sure that you include conio.h (it may be conio.c with DevC++).
Basically a stripped down main with getch() would look like this:
Code:#include "conio.h" //like I said you may need to use conio.c
int main()
{
printf("Hello World!");
getch();
return(0);
}
Another possibility is:
Code:#include <stdlib.h>
int main()
{
/*... do whatever you want to do ...*/
system("PAUSE"); //the program will wait for your input to close
return 0;
}