I'm not sure what is going wrong here

Ok, I have started off with codeblocks and a tutorial I downloaded and I've written my Hello World programm as follows:

// my first program in c++
#include <iostream>
using namespace std;
int main ()
{
cout << "Hello World!";
return 0;
}

I get error messages and it won't compile. Can anyone advise where I'm going wrong?

Thanks.
There's nothing wrong with the code.
If you get error messages, you ALWAYS need post them. Maybe you forgot to install a compiler?
Ok here we go:
C:\Documents and Settings\user\My Documents\C++\Bender02\Bender02.c|2|error: iostream: No such file or directory|
C:\Documents and Settings\user\My Documents\C++\Bender02\Bender02.c|3|error: expected '=', ',', ';', 'asm' or '__attribute__' before 'namespace'|In function 'main':|
C:\Documents and Settings\user\My Documents\C++\Bender02\Bender02.c|6|error: 'cout' undeclared (first use in this function)|
C:\Documents and Settings\user\My Documents\C++\Bender02\Bender02.c|6|error: (Each undeclared identifier is reported only once|
C:\Documents and Settings\user\My Documents\C++\Bender02\Bender02.c|6|error: for each function it appears in.)|

You need to name your file Bender02.cpp.
If you give it a .c extension, it will be treated as C source code.
Cool, it worked thanks.

Ben
Topic archived. No new replies allowed.