代码不会编译

use*_*439 2 c++

我正在使用Microsoft Visual Studio Express 2013并编写了以下代码

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

我收到以下错误

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

2 IntelliSense:预期声明错误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).
Run Code Online (Sandbox Code Playgroud)

Rei*_*ica 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;
}
Run Code Online (Sandbox Code Playgroud)

您应该遵循一个好的教程(或参加课程)以熟悉Visual Studio - 您需要能够区分Intellisense"错误",编译器错误,链接器错误和运行时输出消息来进行任何认真的编程工作.