【发布时间】:2021-08-08 14:23:49
【问题描述】:
我在这里使用的是 Visual Studio 2019 社区版。我从文件->新建->现有项目打开一个文件夹。但是每当我构建和运行我的程序时。它说
无法启动程序 'O:\1.Fourth 学期\programminh\main\Debug\Main2.exe' 系统找不到指定的文件
有很多节目。像bubble.cpp、binary.cpp,但它运行Main2.exe。
这是我的 linear.cpp 文件
#include <iostream>
using namespace std;
int main(){
int n, an, arr[30], key, i, found=0;
cout<<"Please enter number of element you want:"<<endl;
cin>>n;
cout<<"Please enter the numbers"<<endl;
for(i=0;i<n;i++){
cin>>arr[i];
}
cout<<"Please Enter the number you want to search"<<endl;
cin>>key;
for(i=0;i<n; i++){
if(arr[i] == key){
cout<<"Element found at position "<<i+1;
found=1;
break;
}
}
if(!found){
cout<<"Number Not Found"<<endl;
}
return 0;
}
有人可以看看吗?
【问题讨论】:
-
代码似乎是可编译的。 (Test on coliru)。因此,我猜您的 VS 项目配置不正确。你没有透露任何关于这件事的事情。但是...... MS 在他们的网站上有一些(恕我直言非常好的)教程。也许,你应该先从那里开始。
-
它是可编译的。我在代码块中运行它。没关系。但是我在视觉工作室中遇到了错误。即使我选择bubble.cpp,它也会运行我作为项目名称创建的main.exe
-
即使我选择bubble.cpp,它也会运行我作为项目名称创建的main.exe 当然,它确实如此,因为它应该是这样工作的。仅供参考:MS: Solutions and projects in Visual Studio
-
@Scheff 它应该运行bubble.cpp吗?有很多cpp文件。它不应该运行我的目标文件吗?它打开了我第一次运行的程序。
-
好的..我去看看..
标签: c++ visual-studio c++17 visual-studio-2019