Jump to content
  • Advertisement
Sign in to follow this  
Toast-99

Erm..help with Dev C++

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

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!