Sign in to follow this  

Erm..help with Dev C++

This topic is 3729 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

I'm having trouble with Dev C++. When I run and compile my program, there's no errors or anything, but the window it runs in flashes and closes. I don't think I need a sleep command or anything. Any ideas?

Share this post


Link to post
Share on other sites
At the end of the program add a:
system("pause");


There are other ways as well (such as std::cin.get() or _getch()), but the idea is you need to somehow stop execution at the end.

Share this post


Link to post
Share on other sites
I had this problem also when I was starting out, its easily fixed by adding another line of code at near the bottom of your source.

I'm still very new at C++, but 'cin.get();' seems to ring a bell when it comes to fixing that problem.

Basically it stops the program there and waits for user input ("Press any key to continue"..)


Try this for "Hello World!" source;

#include <iostream>

using namespace std;

int main()

{
cout << "Hello World!\n";
cin.get();

return 0;
}



Does that work for you in Dev-C++?


EDIT:: Beat me too it Drew_Benton ;-)

[Edited by - Isnorx on November 2, 2007 12:34:47 PM]

Share this post


Link to post
Share on other sites
the cin.get; works perfect, thanks! I was thinking of possibly putting something in that required input, but I wasn't sure

Share this post


Link to post
Share on other sites

This topic is 3729 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