Search code examples
c++codeblocks

when I build and execute code the console is shutting immediately on codeblock C++


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?


Solution

  • 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.