Jump to content
  • Advertisement
Sign in to follow this  
Death2You

Dev C++

This topic is 4611 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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!