Compiling Error

Ok, I'm an aspiring C++ programmer. I've read up on it, and finally downloaded Visual C++ 2005 Express Edition so I could actually do something with my knowledge. But it's not compliling...and this is the way I was shown how to do "helloworld":

#include <iostream>
using namespace std;

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



I get this error message:

fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source

Well, yeah, I did forget to add it. But where would I add it...and why does it need it It's really irksome to download a new program and have it work right. I'd highly apperciate some help.

I'm much more comfortable with PHP, but I'd really like to learn a lot about C++. So no, I'm not good at it. Just please don't pass me off as just another newbie who doesn't know anything though.



Answer this question

Compiling Error

  • Hongqin Fan

    You're using the "precompiled header" feature of the compiler. This is not really worth the trouble on the "hello world" level. Just open the property page for the project and disable it ( under "C/C++" -> "Precompiled Headers" - change this to "Not Using Precompiled Headers" ). No stdafx.h file is needed without precompiled headers.

    Cheers,
    BBA


  • christieb

    I'm just as much a newbie as you are, but I think I may know what to do. I have taken tutorials online which have shown both ways, so for some programs maybe one way is necessary.

    I don't know why this is, but you might have to put:

    #include <iostream.h>

    instead of

    #include <iostream>

    Try that and see if it works.


  • Compiling Error