Code::Blocks makes me want to shoot myself

Aug 23, 2013 at 3:28pm
I can not get Code::Blocks to work for the life of me. Simple code that works perfectly in VS Express displays a blank command line in Code::Blocks.

Such as this.

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

using namespace std;

int main(){

    cout << "Hello World!" << endl;

    return 0;
}


Created an empty project, added a source file, wrote that code. Does nothing in Code::Blocks, works perfectly in VS.

Same story when trying to use header files, programs with multiple files, etc.

Please help, thanks.
Aug 23, 2013 at 3:37pm
try

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

using namespace std;

int main(){

    cout << "Hello World!" << endl;
    system("pause");

    return 0;
}
Aug 23, 2013 at 3:41pm
The problem is Code::Blocks, not the code.
Aug 23, 2013 at 3:41pm
did you try it?
Aug 23, 2013 at 3:41pm
Better:
1
2
3
4
5
6
7
8
#include <iostream>
#include <limits>

int main()
{
    std::cout << "Hello, world!" << std::endl;
    std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
}
Aug 23, 2013 at 3:47pm

Better:
1
2
3
4
5
6
7
8
#include <iostream>
#include <limits>

int main()
{
    std::cout << "Hello, world!" << std::endl;
    std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
}



I believe you when you say its better but why is it better?
Aug 23, 2013 at 3:51pm
It does not contain "using namespace std;"
It does not use system()

http://www.cplusplus.com/forum/beginner/1988/


@OP the fact that the console is blank and stays open confuses me...are you sure this is exactly what happens?
Last edited on Aug 23, 2013 at 3:52pm
Aug 23, 2013 at 3:57pm
When ran the console shows this:

Process returned 1993471113 (0x76D1F489) execution time : -0.00 s
Press any key to continue.

It certainly does not say "Hello World!"....
Aug 23, 2013 at 3:59pm
Did you try running the program I posted? Most likely the program runs, displays "Hello, world!" and then because you do not code it to stay open, it immediately closes before you have time to see it, and Code::Blocks correctly says it ran successfully and took 0 seconds to do so.
Aug 23, 2013 at 4:02pm
@LB: He would have seen "Hello World!" before "Process returned..." .
Weird problem. Did you get it with MinGW?
Last edited on Aug 23, 2013 at 4:02pm
Aug 23, 2013 at 4:03pm
@EssGeEich: not if "Hello, world!" displayed in the console window and the process info displayed in the box at the bottom of Code::Blocks ;p
Aug 23, 2013 at 4:11pm
@MarketAnarchist

System() is bad, and won't work with Code::Blocks unless he is using a different compiler.

-----

Code::Blocks should keep the console window open without any code so long as you run it from the IDE. Once you run it, it will close just as a program compiled in VS Express would.

If this question is a problem Code::Blocks then I'd ask it on Code::Blocks.

----
General Mistakes However...

1. Make sure have MinGW and Code::Blocks properly installed
2. Make sure you are properly adding files to your project by adding them to Debug/Release, both or whichever you need.
3. Not as general but some people need to run Code::Blocks as an admin or else it'll act funny.
Last edited on Aug 23, 2013 at 4:13pm
Topic archived. No new replies allowed.