Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

C 

Console Window in Code Blocks on Linux Keeps Closing

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;

   
}
return 0; exits the main function.

std::cin.get();

is never ran.
(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;


}

It shouldn't be closing by default.

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


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C#] by DistrictAug 29, 2020 03:33 PM 2 187 Aug 29, 2020 03:33 PM
Last Post: District
[Python] by zioncorpDec 28, 2018 11:13 AM 5 221 Dec 28, 2018 11:13 AM
Last Post: LouisXV
[.NET] by CrakxprooJun 21, 2018 07:34 AM 0 207 Jun 21, 2018 07:34 AM
Last Post: Crakxproo