Why do I get "error C2006: '#include' : expected a filename, found 'identifier' "?
Solution 1
Use double quotes "
to surround stdafx.h
and Hello world!\n
Currently you are using some inverted quotes/quotation marks.
Solution 2
If you copied the code example directly from your source code, it seems that you have Unicode curly double quotes ( Unicode | U+201C (decimal: 8220) ) when the compiler is expecting ASCII double quotes ( ASCII | 34 (hex: 22 | octal: 0042 | binary: 00100010) | Unicode | U+0022 (decimal: 34) )
Anant
Updated on June 04, 2022Comments
-
Anant almost 2 years
My source code in Visual C++ Express 2008 is as follows :
#include “stdafx.h” #include <iostream> int _tmain(int argc, _TCHAR* argv[]) { std::cout << “Hello world!\n”; return 0; }
I'm using the book, Visual C++ 2008,by Ivor Horton
.These are the errors that I'm encountering.How do I get rid of the errors ?
1>e:\my documents\visual studio 2008\projects\hello\hello\hello.cpp(1) : error C2006: '#include' : expected a filename, found 'identifier'
1>e:\my documents\visual studio 2008\projects\hello\hello\hello.cpp(1) : fatal error C1083: Cannot open include file: '': No such file or directoryThanks!
-
Anant over 13 yearsthanks for pointing that out , but i tried it and it doesnt work unfortunately
-
Anant over 13 yearsa whole new set actually : 1>e:\my documents\visual studio 2008\projects\hello\hello\hello.cpp(2) : warning C4067: unexpected tokens following preprocessor directive - expected a newline 1>e:\my documents\visual studio 2008\projects\hello\hello\hello.cpp(5) : error C2065: '“Hello' : undeclared identifier 1>e:\my documents\visual studio 2008\projects\hello\hello\hello.cpp(5) : error C2146: syntax error : missing ';' before identifier 'world'
-
Anant over 13 yearsand : 1>e:\my documents\visual studio 2008\projects\hello\hello\hello.cpp(5) : error C2065: 'world' : undeclared identifier 1>e:\my documents\visual studio 2008\projects\hello\hello\hello.cpp(5) : error C2143: syntax error : missing ';' before '!' 1>e:\my documents\visual studio 2008\projects\hello\hello\hello.cpp(5) : error C2017: illegal escape sequence 1>e:\my documents\visual studio 2008\projects\hello\hello\hello.cpp(5) : error C2065: 'n”' : undeclared identifier
-
codaddict over 13 years@Anant: You also need to change the quotes around your
Hello world!\n