【发布时间】:2021-09-17 10:04:24
【问题描述】:
我正在尝试学习 C++,所以我开始关注 microsoft's calculator tutorial 这是我目前的代码
#include "stdafx.h"
#include <iostream>
using namespace std;
int main()
{
cout << "Calculator Console App" << endl << endl;
cout << "Enter an Operation from the following operations, a+b, a-b, a*b, a/b" << endl;
return 0;
}
但是,当我按 CTRL+F5 启动而不进行调试时,我收到此错误: Unable to start program 'C:\Users\Clark\source\repos\Calculator\Debug\Calculator.exe'. The system cannot find the file specified
#include "stdafx.h" 行中的#include 下方也有一条红线,每当我将鼠标悬停在它上面时,它就会显示cannot open source file "stdafx.h"
我该如何解决这个问题,以便我的代码能够真正运行?
【问题讨论】:
-
在 Visual Studio 2019 中应该是
#include "pch.h"。无论哪种情况,如果您启用了预编译头文件,该文件都是在您的项目文件夹中创建的文件。无论如何,您可能只想禁用预编译的头文件,因为除非您有一个包含大量外部头文件的项目,否则它对您没有任何帮助。 -
无法启动程序当编译失败时你会得到它。如果编译失败,您没有可执行文件可运行..
标签: c++ visual-studio visual-studio-2019