Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Using Microsoft Visual C++

Hello,
I was using Dev-C++ up to now, but then I heard that Microsoft Visual C++ was better. So I got it. But I can't even do the simplest things with it.
Here's the code:

#include <iostream>
using namespace std;

int main()
{
cout <<"Hello World!";
return 0;
}

The error that I get when I try to compile is this:
"fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source?"

Now, when I try to add
#include <stdafx.h>

to the code, I get some more errors:
"error C2871: 'std' : a namespace with this name does not exist", and:
"error C2065: 'cout' : undeclared identifier"

Can anyone help please?
[833 byte] By [Pinny] at [2007-11-11 7:37:21]
# 1 Re: Using Microsoft Visual C++
turn off precompiled headers. Right click your project name and its got its own tab in the c++ settings (I think).
jonnin at 2007-11-11 21:02:06 >
# 2 Re: Using Microsoft Visual C++
Ah yes thank you! It works now. :)
Pinny at 2007-11-11 21:03:00 >
# 3 Re: Using Microsoft Visual C++
turn off precompiled headers. Right click your project name and its got its own tab in the c++ settings (I think).
This gets to be my "annoyance of the decade" when using VC++;)
Danny at 2007-11-11 21:04:11 >
# 4 Re: Using Microsoft Visual C++
The *idea* isnt so bad, but it simply does not work properly.
jonnin at 2007-11-11 21:05:05 >