Error C1004: Unexpected end of file found in Visual Studio 2012

I want to write simple C ++ code in visual studio 2012, but always get error C1004 in the header file. Can anyone help me out?

My code is below. I am new to C ++ visual studio, so this can be a very stupid mistake.

add.cpp

#include <iostream> int add(int a, int b) { return a+b; } 

add.h

 #ifndef ADD_H #define ADD_H int add(int a, int b); #endif 

source.cpp

 #include "add.h" #include <iostream> int main() { std::cout << add(3, 4); return 0; } 
+6
source share
1 answer

The general code looks fine, but add.h will need a carriage return at the end of the file. Here is the Microsoft documentation for this error code:

http://msdn.microsoft.com/en-us/library/4exw7xyc%28v=vs.110%29.aspx

+11
source

All Articles