Code::Blocks Forums
User forums => Help => Topic started by: Mr.Ninja on January 02, 2012, 03:53:37 am
-
Hello,
I am just learning C++ and am getting info off of www.cprogramming.com. I have a basic program which won't run properly. First I hit new, and then select console application. I make sure it is C++ and then name it and do the default setting. I tthen create my program;
include <iostream>
using namespace std;
int main()
{
cout<<"HEY, you, I'm alive! Oh, and Hello World!\n";
cin.get();
}
I hit the debugger and it gives me this;
Building to ensure sources are up-to-date
Build succeeded
Selecting target:
Debug
Adding source dir: C:\Users\David\Desktop\Personal\Poof\Library\
Adding source dir: C:\Users\David\Desktop\Personal\Poof\Library\
Adding file: bin\Debug\Library.exe
Starting debugger:
done
Registered new type: wxString
Registered new type: STL String
Registered new type: STL Vector
Setting breakpoints
Debugger name and version: GNU gdb 6.8
Continuing...
The program is not being run.
Debugger finished with status 0
It does not allow me to start it as it says it is not built yet, but when I build it;
-------------- Build: Debug in Library ---------------
Linking stage skipped (build target has no object files to link)
Nothing to be done.
I do not know what to do.
-
(1) First of all, your int main() needs to return something. Add return 0. This is an error but you seem not to get any error messages. A possible reason is a "default code" added by project wizard to your project automatically. Therefore
(2) Check your project and remove all files which are not yours from it.
(3) Try again.
-
First of all, your int main() needs to return something. Add return 0. This is an error
It's not an error in C++ - main does not require an explicit return.
-
http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F (http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F)
Turn on Full Compiler logging and then do a full rebuild. The compiler log should show what it did; read/post it and the cause should be able to be found.
Tim S.
-
Preprocessor commands needs # before them.
Ex.:
#include <iostream>
-
Thank you stahta01 I have done that and this is where it says it stops working when I run it:
123 (red bar) operator(_ios_type& (*_pf)(_ios_type&))
On the build message:
c:\program file... 123 error: expected type-specifier before '(' token|
c:\program file... 123 error: expected ';' before '(' token|
c:\program file... 129 error: expected ';' before '__istream_type'|
||=== Build finished: 3 errors, 0 warnings ===|
thanks for the help.
And maxum, not trying to be rude, but when I was copying and pasting I missed the # sign.
-
1. Copy your program source code somewhere outside of the "program files" folder.
It is NOT considered safe or easy to compile files in the "program files" folder.
2. Fix the compiler errors.
Tim S.