When I compile and run a program in devc++ the results screen flashes and goes away. Only way I have found to see results is to add an scanf and then the screen stay up to veiw. Any one know what I can do.
When I compile and run a program in devc++ the results screen flashes and goes away. Only way I have found to see results is to add an scanf and then the screen stay up to veiw. Any one know what I can do.
Yes.
Newer release:
#include <iostream>
#include <stdlib.h>
using namespace std;
int main()
{
cout<<"Hello world!\n";
system("PAUSE");
return 0;
}
Dev-C++ 4.1:
#include <stdlib.h>
#include <stdio.h>
int main()
{
printf("Hello world!\n");
system(PAUSE");
return 0:
}
Hope this helps.
You can put at the end of your program:
The system() function is declared in stdlib.Code:system("pause");
thks for the info I appreacite it very much.
I will never understand why people feel the need to use this. Why not use:Originally posted by Vber
You can put at the end of your program:
The system() function is declared in stdlib.Code:system("pause");
getchar( );
Quzah.
Hope is the first step on the road to disappointment.
Quzah, Sometimes getchar() alone don't works for me, he don't pause the program, system("pause"); works always.
Why, have something wrong with this function?
It's generally considered a good idea to avoid system calls when you can. The reason getchar() won't work for you is that there's probably something left over in your input stream before the check.Originally posted by Vber
Why, have something wrong with this function?
That should work. Either one is fine. You can use system() if you like. Most people tend to avoid it.Code:void mypause( void ) { while( getchar( ) != '\n' ); printf("Press enter to exit."); getchar( ); }
Quzah.
Hope is the first step on the road to disappointment.