C++ – error C1083: Cannot open include file: ‘stdafx.h’: No such file or directory in VS 2005

cwindows

I am new to visual studio.I have created a simple console application and then selected an empty project of c++.
I have pasted the code form
http://www.cprogramming.com/tutorial/opengl_first_windows_app.html

it is giving the following error
error C1083: Cannot open include file: 'stdafx.h': No such file or directory.

Can any body help me how ti solve that issue.

Also i have pasted the code from
http://www.cprogramming.com/tutorial/opengl_windows_programming.html

and it gives me error in MessageBox function.

Best Answer

Fall in the pit of success by using an appropriate project template. Which is Win32 + Win32 Project, don't tick the "Empty project" option on the property page. You'll get pre-generated code for a Win32 application, take a look at it since you might want to keep parts of it. Or just delete it all past the #include for stdafx.h and replace it with the code you want to try. The stdafx.h file is already pre-cooked for you.

The second snippet probably fails to compile because the code sample is not using Unicode strings. Put an L in front of the string literal, like L"\tHello world".

Related Topic