Sign in to follow this  

Dev C++

This topic is 4307 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

In school I use Visuall C++ 6.0 and when i ake a simple problem like hello world it stays up and doesnt disappear. Then i'm using this beta program Dev C++ and the program exits wiith a second. How do I make it stay up for as long as i want?

Share this post


Link to post
Share on other sites
Three ways:
- run it from a console window
- add the line system("pause"); before the end of main.
- have the user do some input, for example:
std::string pause;
std::cin >> pause;

Share this post


Link to post
Share on other sites
You can add:

#include <conio.h>

to the top of the file with your main function and then add

_getch();

just before the end of your main function.
Cheers!

Share this post


Link to post
Share on other sites
The easiest way is to:
#include<windows.h>
#include <iostream>
using namespace std;
int main ()
{
cout << "Hello world\n";
Sleep (5000); \\ (1000) is one second, and Sleep's "s" has to be captilazed
return 0;
}

Share this post


Link to post
Share on other sites
This way:


#include <iostream>
using namespace std;

int main()
{
cout<<"Hello World!"<<Endl;
cin.get(); //waits for the user to press enter
return 0;
}



Or you can run the console and run it from there.

Chad.

Share this post


Link to post
Share on other sites

This topic is 4307 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this