error for visual c++

Questions about programming languages and debugging
Post Reply
User avatar
Swan
Knight of the Sword
Knight of the Sword
Posts: 827
Joined: 18 Oct 2006, 16:00
17
Contact:

error for visual c++

Post by Swan »

Using visual c++ 6.0

tried to execute the following code:

include <iostream>
#include <string>
using namespace std;

// Prompt the user to enter a name, collect the name,
// and display a message to the user that contains
// the name.
int main()
{
string userName;

cout << "What is your name? :";
cin >> userName;
cout << "Hello " << userName << "!" << endl;

return 0;
}

The following error appeared.

fatal error C1010 - unexpected end of file while looking for precompiled header directive.

I googled it, and have found that #include "stdafx.h" has to inserted into the source code. I have done so, but still get the error. :? :?:

User avatar
Stavros
ΜΟΛΩΝ ΛΑΒΕ
ΜΟΛΩΝ ΛΑΒΕ
Posts: 1098
Joined: 02 Jan 2006, 17:00
18
Location: Mississippi, U.S.A.

Post by Stavros »

I noticed you're missing "#" in front of "include<iostream>.

And you're using MSVS6.0, so you'll always need to include "#include "stdafx.h" into the header.

Post Reply