User forums > Help
New to code blocks - compiling and decompiling
Alpha:
--- Quote from: chessguy on January 10, 2012, 01:20:39 am ---When I do auto detect, it switches to:
C:\Program Files\Microsoft Visual Studio 8\VC
[...]
Currently, The code blocks folder (and thus, MinGW within) are located directly on c:\
--- End quote ---
Go to Settings->Compiler and debugger... and select "GNU GCC Compiler" from the drop-down menu at the top.
Now use auto detect.
chessguy:
Ah... that did something. I had had it on that, but it was when I typed it (looked the same, though) because it always seemed to revert back. Now, when I debug, it actually tells me if and where I did something wrong, very useful. However... and, for learning purposes, I am working on consoles.
I know that, when they are done exuciting, it will close. However, I want to see the program output. I added a part ot it which would, in theory, make it wait for the input of the user using cin, but it just opens and closes still. Like this:
#include <iostream>
using namespace std;
int main()
{
cout << "Hello world!" << endl;
return 0;
int x;
cin >> x;
cout << x << endl;
}
I realize that is more of a code thing, but in the debugger I used before, this would make it wait, so I am wondering...
Also, - I haven't compiled anything yet... it no longer gives errors when I do it, but trying "build", "run", build AND run, etc, don't seem to have effect. Bit confused. I should probbably read up on that article a bit more now that it has a chance of working, though.
THanks.
Alpha:
Yes, pausing to see what happened is nice :).
The problem with your method is that your program exits as soon as it reaches return 0; (it never reaches your other statements).
I normally pause with:
--- Code: ---#include <iostream>
using namespace std;
int main()
{
cout << "Hello world!" << endl;
cout << "Press enter to close program"; //Let the user know the program is done.
cin.sync(); //Clear the buffer (just in case).
cin.get(); //Wait for the enter key.
return 0; //Exit the program.
}
--- End code ---
MortenMacFly:
Locking topic now,.
We are not a "Teaching C++" forum. Try a more appropriate forums for such questions, please understand.
Navigation
[0] Message Index
[*] Previous page
Go to full version