# simple "hello world" code using c++



## huck (Sep 30, 2002)

Could someone post simple code for a c++ project.  I'm using project builder and would liek to compile some code.  However, i'm not having any luck.  all i would like to see is a cout statement.

cout << "hello world" << endl;

that's it.  Please include all libraries needed.  A screen shot within project buiilder would key.

Peace.

Ver


----------



## r4bid (Sep 30, 2002)

Are you just typing that in and trying to get it to print out "Hello World" or do you have a main function and preprocessor directives to load the required header files?  
I need to know exactly what you have typed and what message you are getting when you try to compile to truely help you...


----------



## huck (Sep 30, 2002)

just want that simple statement outputted.  nothing else.  there will be no input.  simply run the program and get that output.

This just so i can see how to properly get code to compile in project manager.  I have an intro class for c++ and i need to get the project manager to compile my code.

Ver


----------



## davidbrit2 (Oct 1, 2002)

If it's an introductory C++ course, you might be better off just building the source code from the command line rather than trying to learn the IDE and language at the same time. You could just make a plain text source file called hello.cpp that might look something like this:


```
#include <iostream.h>

int main(void) {
	cout << "Hello world.\n";
	return 0;
}
```
(I have no idea if this program would work; I'm not a C++ guy.)

Then just use g++ from Terminal. The basic syntax is "g++ inputfile -o outputfile".

I do Java programming like this all the time. Basically, just use Project Builder to edit the text files (without creating a project,) and compile and run from Terminal.


----------

