2014-03-03 214 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「錯誤」,編譯器錯誤,鏈接器錯誤和運行時輸出消息,以執行任何嚴肅的編程工作。