All of a sudden my program refuse to execute

Sep 9, 2013 at 12:01pm
I was working on a very simple program that only uses the cmd to do stuff.
Then all of a sudden it stopped working.
It compiles and runs. But it instantly return 0; in main, without even running the code inside main!

I realised not even this line of code will run anymore:
1
2
3
4
5
6
7
8
#include <iostream>

using namespace std;
int main(){

    cout << "running";
    return 0;
}

It will only print "Process returned 0 (0x0)"...

I think my friend made an extra setting to allow to work with windows and buttons, but Im not sure what he did.
Im using codeblocks so maybe that is the error?
Sep 9, 2013 at 1:34pm
He's probably set your code to run in GUI mode, which completely removes the Console window.
Try creating another project in Console mode.
Sep 9, 2013 at 2:34pm
Check that. It is running console mode not gui mode :/
Sep 9, 2013 at 3:52pm
Maybe you should try resetting all the settings back to default? that might solve it.
Sep 9, 2013 at 5:11pm
Uninstalled and reinstalled the whole ide. Copy pasted the text in the files so that no config file would enter my new project.
Still, same problem remains. God I hate when shit like this happens to newbies.
Sep 9, 2013 at 5:52pm
Do you have to Log window visible in Code Blocks? Is it displaying anything funny when you go to compile the code again?
Sep 10, 2013 at 5:48am
When I compile it says:
1
2
3
4
5
6
mingw32-g++.exe -Wall  -g     -c "C:\Users\Andreas\C++ Workspace\Testit\MainClass.cpp" -o obj\Debug\MainClass.o
mingw32-g++.exe -Wall  -g     -c "C:\Users\Andreas\C++ Workspace\Testit\Player.cpp" -o obj\Debug\Player.o
mingw32-g++.exe  -o bin\Debug\Testit.exe obj\Debug\MainClass.o obj\Debug\Player.o   -mwindows  
Output size is 979.95 KB
Process terminated with status 0 (0 minutes, 1 seconds)
0 errors, 0 warnings (0 minutes, 1 seconds)

Perhaps it's that -mwindows that buggs it.. But Im not sure how to get rid of it..
Sep 10, 2013 at 3:05pm
It was the -mwindows that bugged me.
It was in settings>compiler>linker
something was written -mwindows
and that made the program run wrong main function I think..
Sep 10, 2013 at 3:46pm
-mwindows is used only when you write a GUI program, not a console application.
Topic archived. No new replies allowed.