Quote:Original post by sneaky_squirrel I did what you said and got the following:
------ Build started: Project: Hi, Configuration: Debug Win32 ------ Compiling... Hi.cpp c:\documents and settings\compaq_administrator\my documents\visual studio 2008\projects\hi\hi\hi.cpp(3) : fatal error C1083: Cannot open include file: 'stdafx.h': No such file or directory Build log was saved at "file://c:\Documents and Settings\Compaq_Administrator\My Documents\Visual Studio 2008\Projects\Hi\Hi\Debug\BuildLog.htm" Hi - 1 error(s), 0 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Is there a file named 'stdafx.h' in your project? If not, make sure that you remove the line '#include "stdafx.h"' from your hi.cpp file. After which, you should recompile the project. I am guessing that you might not have this file in your project and are trying to include it in your source code.
when starting a new project, in the wizard that pops up to select what kind of project, choose win32 console app, then on the next screen, make sure its an empty project.
I did just that, copy and pasted your code and it worked just fine, and you don't need to include stdafx.h, also I'd get rid of the "using std namespace, and use the namespace prefixs on the cout like so.
------ Build started: Project: Hello, Configuration: Debug Win32 ------ Compiling... Hello.cpp c:\documents and settings\compaq_administrator\my documents\visual studio 2008\projects\hello\hello\hello.cpp(5) : error C2143: syntax error : missing ';' before '<<' c:\documents and settings\compaq_administrator\my documents\visual studio 2008\projects\hello\hello\hello.cpp(5) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\documents and settings\compaq_administrator\my documents\visual studio 2008\projects\hello\hello\hello.cpp(5) : error C2371: 'std::cout' : redefinition; different basic types c:\program files\microsoft visual studio 9.0\vc\include\iostream(53) : see declaration of 'std::cout' c:\documents and settings\compaq_administrator\my documents\visual studio 2008\projects\hello\hello\hello.cpp(9) : error C2065: 'cout' : undeclared identifier Build log was saved at "file://c:\Documents and Settings\Compaq_Administrator\My Documents\Visual Studio 2008\Projects\Hello\Hello\Debug\BuildLog.htm" Hello - 4 error(s), 0 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I tried adding the directories and I got the following error message:
------ Build started: Project: Hello, Configuration: Debug Win32 ------ Compiling... Hello.cpp c:\documents and settings\compaq_administrator\my documents\visual studio 2008\projects\hello\hello\hello.cpp(5) : error C2143: syntax error : missing ';' before '<<' c:\documents and settings\compaq_administrator\my documents\visual studio 2008\projects\hello\hello\hello.cpp(5) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\documents and settings\compaq_administrator\my documents\visual studio 2008\projects\hello\hello\hello.cpp(5) : error C2371: 'std::cout' : redefinition; different basic types c:\program files\microsoft visual studio 9.0\vc\include\iostream(53) : see declaration of 'std::cout' c:\documents and settings\compaq_administrator\my documents\visual studio 2008\projects\hello\hello\hello.cpp(9) : error C2065: 'cout' : undeclared identifier Build log was saved at "file://c:\Documents and Settings\Compaq_Administrator\My Documents\Visual Studio 2008\Projects\Hello\Hello\Debug\BuildLog.htm" Hello - 4 error(s), 0 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
If anyone understands any of this gibberish for making a simple program that inserts text I'd depreciate it.
Also for the future, are these problems very common? That happen all the time and you have to spend 10 minutes figuring out, I find it very hard to understand these languages...very complicated, so can anyone guide me towards the next step?