V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
wvc
V2EX  ›  问与答

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

  •  
  •   wvc · 2018-06-29 10:45:46 +08:00 · 682 次点击
    这是一个创建于 2140 天前的主题,其中的信息可能已经有所发展或是发生改变。

    使用 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"”?
    这是咋回事啊?

    2 条回复
    ysc3839
        1
    ysc3839  
       2018-06-29 11:32:31 +08:00 via Android
    因为你创建项目的时候开启了预编译头。你应该使用 Windows 桌面向导,创建时可以取消选择预编译头。
    wvc
        2
    wvc  
    OP
       2018-06-29 11:45:38 +08:00
    @ysc3839 哈哈,解决了,学 C++第一个坑,博客终于也有素材了……
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1090 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 19:43 · PVG 03:43 · LAX 12:43 · JFK 15:43
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.