1

I am new to vc++.

#include<iostream.h>

void main()
{
    cout<<"hi this is vc++";
}

Compiling...

h.cpp

c:\program files\microsoft visual studio\myprojects\new1\h.cpp(7) : fatal error C1010: unexpected end of file while looking for precompiled header directive Error executing cl.exe.

h.obj - 1 error(s), 0 warning(s)

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
piru
  • 11
  • 1
  • Two significant problems with your code. First, `void main` is wrong. The correct return type is `int`, so it is always prototyped as `int main`. Second, you need to be using `std::cout`. The code shown here wouldn't compile, unless you had `using namespace std;` somewhere, which is not something you should really be doing. – Cody Gray - on strike Sep 09 '16 at 15:49

1 Answers1

1

Visual C++ uses precompiled headers by default, this feature speeds up compilation but it means you need to have a #include "stdafx.h" at the top of your cpp files.

An alternative is to turn off precompiled headers. Here is how to do it (source and more detail here):

In Visual Studio 2010, this setting is controlled from the GUI via Right-clicking on a CPP Project, selecting 'Properties' and navigating to "Configuration Properties\C/C++\Precompiled Headers". For other versions of Visual Studio, the location in the GUI will be different.

Community
  • 1
  • 1
CiscoIPPhone
  • 9,457
  • 3
  • 38
  • 42