At the first step

Hi!
My name is reza.
I've just written my "hello world" program. It didn't work!
My code was:
-----
#include <iostream.h>
int main ()
{
cout<<"Hello world";

return 0;
}
-----
I am using Visual studio 2008.
At the end of compilling it give's me
-----
1 error(s), 1 warning(s)
-----
I don't know how to find the wrong part.
Can you help me please?
I'm not sure, but I what I think you're missing is
1
2
3
4
5
6
7
8
9
10
11
12

#include <iostream.h>

using namespace std;           // this

int main ()
{
cout<<"Hello world";

return 0;
}
Sup reza, You didn't include the line using namespace std; place it after #include <iostream>
and before int main()
Actually, as a beginner it might be better to just specify the standard namespace with std::cout rather than confusing things with the using directive. It may mean a bit more typing but you avoid namespace clashes that could be very frustrating when you're just starting out.

Also, <iostream.h> is a deprecated C language header. Use <iostream> for the up-to-date C++ version. http://www.devx.com/tips/Tip/14447
1
2
3
4
5
6
7
8
9
10
#include <iostream>
using namespace std;

int main()
{
    cout << "Hello World\n";
    
    system("PAUSE");
    return 0;
}
BTW, if you look at the bottom window in VS2008 you should have an Output tab. That is the place where it will explain the errors and warnings. You will get a (sometimes) helpful error description and the line number of the code where the error occurred (or at least close).
One more thing:

DON'T use system("PAUSE"); http://cplusplus.com/forum/beginner/1988/

In VS just use Start without Debugging (cntl-F5). It will pause the output window for you automagically.
Topic archived. No new replies allowed.