I tried some solves that system("pause") / adding getcha() but none of them worked.
#include <iostream>
using namespace std;
int main() {
cout << "hello world" << endl;
return 0;
}
What should I do?
CodePudding user response:
Your code is most definitely valid. The reason it's shutting down is just the way Code::Blocks is set up.
You can follow the instructions here to make the console stay open after executing the program.
CodePudding user response:
you can write such code before return
int a;
cin>>a;
it will wait for input and the console will not close.
CodePudding user response:
using system("pause");
or getch();
is the only way of doing so, as it is mentioned on every place and it works fine with me. maybe there is some problems with your IDE. Just make sure of one more thing that you should #include <conio.h>
before using getche() as it is defined on that directory.