wvc
V2EX  ›  问与答

有没有会 C++的,这个错误是怎么回事?

  •  
  •   wvc · Jun 29, 2018 · 1083 views
    This topic created in 2900 days ago, the information mentioned may be changed or developed.

    使用 Visual Studio 2017 写 c++ primer plus 第 6 版里面的第一个程序就遇到问题了……
    书中源代码如下:

    #include <iostream>                           
    int main()                                    
    {                                             
        using namespace std;                      
        cout << "Come up and C++ me some time.";  
        cout << endl;                             
        cout << "You won't regret it!" << endl;        
        return 0;                                 
    }                                             
    

    在 Visual Studio 2017 里面运行时报错:

    fatal error C1010: 在查找预编译头时遇到意外的文件结尾。是否忘记了向源中添加“#include "stdafx.h"”?
    这是咋回事啊?

    ysc3839
        1
    ysc3839  
       Jun 29, 2018 via Android
    因为你创建项目的时候开启了预编译头。你应该使用 Windows 桌面向导,创建时可以取消选择预编译头。
    wvc
        2
    wvc  
    OP
       Jun 29, 2018
    @ysc3839 哈哈,解决了,学 C++第一个坑,博客终于也有素材了……
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2898 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 05:31 · PVG 13:31 · LAX 22:31 · JFK 01:31
    ♥ Do have faith in what you're doing.