ok im new so i dont really know what im doing but when i put the example program in dev and compile it everything works fine but when i run it it still works fine but the black screen what shows you the result of thr program lasts like 1 second
#include <iostream.h>

int main ()
{
       cout << "hi world \n";
       return 0;
}

the result lasts less than a second how do i fix this

Recommended Answers

Clearly you didn't search the forums before asking this question, because it's very common. You need to add a pause at the end of the program because the IDE allocates a console window for it to run. When the program ends, the window is destroyed and closes. The Dev-C++ code …

Jump to Post

All 2 Replies

Clearly you didn't search the forums before asking this question, because it's very common. You need to add a pause at the end of the program because the IDE allocates a console window for it to run. When the program ends, the window is destroyed and closes. The Dev-C++ code examples (which you also clearly didn't read) use the system function:

#include <iostream.h>
#include <stdlib.h>

int main()
{
    cout << "hi world\n";
    system("PAUSE");
    return 0;
}

Though that's not a recommended practice, it'll suffice until you're ready to tackle the not so trivial issues involved in better solutions.

When you get that sorted out, don't forget to please stop using Dev-C++ and move to something far, far better. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.