I don't know how to pause the screen 2

Pages: 12
closed account (2LzbRXSz)
http://stackoverflow.com/questions/10363646/compiling-c11-with-g

Maybe this will work...?

Honestly, it may be in your best bet to download a different IDE.
Now I understood why I got the error . I must restart my computer along with Dev C++ 5.11 after making the change :)

So I tried your code Cactus and it worked fine . but the

press a key to continue... message did not disappear : When I run your code :

1
2
3
4
5
6
7
8
9
10
11
12
13
#include <iostream>
#include <thread>
#include <chrono>

using namespace std;

int main()
{
    this_thread::sleep_for(chrono::seconds(5));
    cout << "Hello, world!" << endl;
    
    return 0;
}


this is what I got :

Hello , world !

-----------------------------------------------------

process exited after 5.049 seconds with return value 0

press a key to continue ...

So the message remained and did not disappear

is not there a solution to make the message disappear ?


Open a terminal/command prompt change directory to where the executable is and run it.
Here is what I do to make it so you have to press a key to continue.

1
2
3
4
5
6
7
8
9
10
11
12
#include<iostream>              //for cout
#include<conio.h>               //for getch()
using namespace std;
int main(void)
{
    int k=0;                    //variable
    cout << "press something anything i need to be free" << endl;//message to tell the user to press a key to continue
    k=0;while(k==0) k=getch();  //pausing sequence
    cout << "thanks" << endl;   //something afterwards to prove it works
    return (0);
}


Also, never use system("pause"); or any system command because... well... just read this article.

http://www.cplusplus.com/articles/j3wTURfi/
"Open a terminal/command prompt change directory to where the executable is and run it."

thank you that is really wonderful idea and it works . Is there a way to do it automatically without having each time to change to where the executable is then running it ???
You can probably set up your IDE to do that automatically with some custom debug/run options. I'm not sure where those would be in DevC++ though, probably in some project/program properties window.

Also, consider upgrading to a more recent IDE like wxDevC++ (or whatever is the newest).
@thecrazedone126 your solution is not the best. First, why to declare new, unused variable?
You can do sth like that:
while(true) getch();
Second, those kind of loops are horrible. They run all the time. It uses all processor resources it can. It's much better to use std::cin.get();. It doesn't make that ugly loop. Use it once normally or twice if there was std::cin >> something; before, as it has to catch enter key, that was not caught by std::cin object.
dilver, you can also compile it as release. That "press any key to continue" is code added to the end of the run by the compiler in a debug compilation.
"dilver, you can also compile it as release"

What do you mean?
Topic archived. No new replies allowed.
Pages: 12