Hack Forums
[C] Console Window in Code Blocks on Linux Keeps Closing - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [C] Console Window in Code Blocks on Linux Keeps Closing (/showthread.php?tid=5762864)



Console Window in Code Blocks on Linux Keeps Closing - Kovaska - Dec 4, 2017

Everything was working fine when I was on Windows. I'm using codeblocks on linux now and the console window opens for less than a second. I'm using a basic hello world program just as an example. I added std::cin.get(); and it still isn't working. I even looked at the settings and it says it is supposed to stay open when the program runs.

Code
#include <iostream>

int main()
{
    std::cout << "Hello world!" << std::endl;

    std::cin.get();

    return 0;

   
}



RE: Console Window in Code Blocks on Linux Keeps Closing - Mouse❤️ - Dec 4, 2017

return 0; exits the main function.

std::cin.get();

is never ran.


RE: Console Window in Code Blocks on Linux Keeps Closing - Kovaska - Dec 4, 2017

(Dec 4, 2017 03:29 PM)Mouse❤️ Wrote:  return 0; exits the main function.

std::cin.get();

is never ran.

That was a sloppy mistake on my part in writing this post. This is what I actually meant.

Code
#include <iostream>

int main()
{
   std::cout << "Hello world!" << std::endl;

   std::cin.get();

    return 0;


}




RE: Console Window in Code Blocks on Linux Keeps Closing - Hoodie+ - Dec 5, 2017

It shouldn't be closing by default.

Make sure subsystem or project is set to console and not empty or GUI.