首页 文章

Microsoft Visual Studio 17错误编译[重复]

提问于
浏览
2

这个问题在这里已有答案:

您好我编译和运行程序时遇到问题 . 我刚刚从code :: block切换到microsoft visual 2017 .

错误:无法启动程序'c:\ users \ myname \ documents \ visual studio 2017 \ Projects \ ConsoleApplication1 \ Debug \ ConsolApplication1.exe'系统找不到指定的文件 .

#include <iostream>
#include <math.h>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include "stdafx.h"
using namespace std;

int main()
{
    cout << "hello";
    return 0;
}

康索尔:

1> ------ Build build:Project:ConsoleApplication1,Configuration:Debug Win32 ------ 1> ConsoleApplication1.cpp 1> c:\ users \ myname \ documents \ visual studio 2017 \ projects \ consoleapplication1 \ consoleapplication1 \ consoleapplication1.cpp(13):错误C2065:'cout':未声明的标识符1>完成构建项目“ConsoleApplication1.vcxproj” - 失败 . ==========构建:0成功,1失败,0最新,0跳过==========

1 回答

  • 1

    由于我不知情的原因,Visual Studio中的编译器忽略了stdafx.h包含之上的任何内容 .

    解决方案:重新排序包含以将 #include "stdafx.h" 置于顶部 .

    备用解决方案:删除 #include "stdafx.h"disable precompiled headers .

    以下内容可能对您有所帮助:Purpose of stdafx.h

相关问题