Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do I get "error C2006: '#include' : expected a filename, found 'identifier' "?

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 directory

Thanks!

like image 600
Anant Avatar asked Dec 16 '22 21:12

Anant


2 Answers

Use double quotes " to surround stdafx.h and Hello world!\n

Currently you are using some inverted quotes/quotation marks.

like image 71
codaddict Avatar answered Feb 01 '23 23:02

codaddict


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) )

like image 28
teukkam Avatar answered Feb 01 '23 23:02

teukkam