User forums > Help

Basic program won't work!

(1/2) > >>

Mr.Ninja:
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.

Radek:
(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.

zabzonk:

--- Quote ---First of all, your int main() needs to return something. Add return 0. This is an error
--- End quote ---

It's not an error in C++ - main does not require an explicit return.

stahta01:
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.

maxum:
Preprocessor commands needs # before them.
Ex.:
#include <iostream>

Navigation

[0] Message Index

[#] Next page

Go to full version