2014-03-03 162 views
2

我使用微软的Visual Studio Express的2013年写了下面的代码代码不会编译

#include <iostream> 
using namespace std; 
int main() 
{ 
    cout << "Hello world!"; 
    return 0; 
} 

我收到以下错误

1智能感知:PCH警告:找不到合适的标题停止位置。未生成IntelliSense PCH文件。

2智能感知:预期声明 错误3错误C1010:查找预编译头时出现意外的文件结尾。你忘了添加'#include“stdafx.h”'到你的源?

我试过添加'#include“stdafx.h”但这没什么区别。我有预编译的头部打勾,如果我解开它,我会在尝试构建时收到以下消息。

'ConsoleApplication6.exe' (Win32): Loaded 'C:\Users\Justin\Desktop\ConsoleApplication6\Debug\ConsoleApplication6.exe'. Symbols loaded. 
'ConsoleApplication6.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ntdll.dll'. Cannot find or open the PDB file. 
'ConsoleApplication6.exe' (Win32): Loaded 'C:\Windows\SysWOW64\kernel32.dll'. Cannot find or open the PDB file. 
'ConsoleApplication6.exe' (Win32): Loaded 'C:\Windows\SysWOW64\KernelBase.dll'. Cannot find or open the PDB file. 
'ConsoleApplication6.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcp120d.dll'. Cannot find or open the PDB file. 
'ConsoleApplication6.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcr120d.dll'. Cannot find or open the PDB file. 
'ConsoleApplication6.exe' (Win32): Loaded 'C:\Windows\SysWOW64\guard32.dll'. Cannot find or open the PDB file. 
'ConsoleApplication6.exe' (Win32): Loaded 'C:\Windows\SysWOW64\user32.dll'. Cannot find or open the PDB file. 
'ConsoleApplication6.exe' (Win32): Loaded 'C:\Windows\SysWOW64\gdi32.dll'. Cannot find or open the PDB file. 
'ConsoleApplication6.exe' (Win32): Loaded 'C:\Windows\SysWOW64\lpk.dll'. Cannot find or open the PDB file. 
'ConsoleApplication6.exe' (Win32): Loaded 'C:\Windows\SysWOW64\usp10.dll'. Cannot find or open the PDB file. 
'ConsoleApplication6.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcrt.dll'. Cannot find or open the PDB file. 
'ConsoleApplication6.exe' (Win32): Loaded 'C:\Windows\SysWOW64\advapi32.dll'. Cannot find or open the PDB file. 
'ConsoleApplication6.exe' (Win32): Loaded 'C:\Windows\SysWOW64\sechost.dll'. Cannot find or open the PDB file. 
'ConsoleApplication6.exe' (Win32): Loaded 'C:\Windows\SysWOW64\rpcrt4.dll'. Cannot find or open the PDB file. 
'ConsoleApplication6.exe' (Win32): Loaded 'C:\Windows\SysWOW64\sspicli.dll'. Cannot find or open the PDB file. 
'ConsoleApplication6.exe' (Win32): Loaded 'C:\Windows\SysWOW64\cryptbase.dll'. Cannot find or open the PDB file. 
'ConsoleApplication6.exe' (Win32): Loaded 'C:\Windows\SysWOW64\version.dll'. Cannot find or open the PDB file. 
'ConsoleApplication6.exe' (Win32): Loaded 'C:\Windows\SysWOW64\imm32.dll'. Cannot find or open the PDB file. 
'ConsoleApplication6.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msctf.dll'. Cannot find or open the PDB file. 
'ConsoleApplication6.exe' (Win32): Loaded 'C:\Windows\SysWOW64\fltLib.dll'. Cannot find or open the PDB file. 
The program '[4872] ConsoleApplication6.exe' has exited with code 0 (0x0). 
+2

这是为什么标记为VB.NET? –

+0

这听起来像是你搞砸了一些设置或删除了文件,并用你自己的文件替换了它们。我建议从一个新项目开始,并从他们提供的文件开始。 – crashmstr

+0

嗨,我完全重新安装Visual Studio,没有工作。 – user3375439

回答

5

stdafx.h的问题最好通过简单地不使用预编译头解决了,你不需要他们的测试程序。

“当您尝试构建时,您不会收到消息列表。这些是运行时间消息 - 您的文件已经构建并成功运行(退出代码0成功)。只是程序立即终止。

您可以添加这样的事情你的程序等待一些输入:

#include <iostream> 
using namespace std; 
int main() 
{ 
    cout << "Hello world!"; 
    cin.get(); // this will wait for a single character press 
    return 0; 
} 

您应该遵循一个很好的教程(或上课),以熟悉的Visual Studio - 你需要能够分辨Intellisense“错误”,编译器错误,链接器错误和运行时输出消息,以执行任何严肃的编程工作。