“系统找不到指定的文件".运行C ++程序时 [英] "The system cannot find the file specified" when running C++ program
问题描述
我安装了Visual Studio2010.我编写了一个简单的代码,我确定它是正确的,但是不幸的是,当我运行代码时,出现以下错误.
I installed Visual Studio 2010. I wrote a simple code which I'm sure is correct but unfortunately, when I run the code, I get the error below.
这是我的代码:
#include<iostream>
using namespace std;
int main (){
cout <<"Hello StackOverFlow ;)";
return 0;
}
这是错误:
无法启动程序'C:\ Users \ Soheil \ Desktop \ New folder \ sam \ Debug \ sam.exe 系统找不到指定的文件
Unable to start program 'C:\Users\Soheil\Desktop\New folder\sam\Debug\sam.exe The system cannot find the file specified
您能帮我解决问题吗?我应该在一个项目中定义项目吗 具体目录?我花了很多时间来解决这个问题, 还没有成功.
Would you help me solve the issue? Should I define the project in a specific directory? I've spent a ton of hours to solve this issue and have not had any success yet.
推荐答案
这是初学者的第一步.我也发生了同样的事情:
This is a first step for somebody that is a beginner. Same thing happened to me:
在左侧的解决方案资源管理器框中查看.确保那里确实有一个.cpp
文件.您可以通过查看存储项目的.sln
文件的.cpp
文件来执行相同的操作.如果没有,那么您将得到该错误.
Look in the Solution Explorer box to the left. Make sure that there is actually a .cpp
file there. You can do the same by looking the .cpp
file where the .sln
file for the project is stored. If there is not one, then you will get that error.
添加cpp文件时,您要使用添加新项图标. (上面有金星的左上方,将鼠标悬停在上面可以看到名称).出于某种原因, Ctrl + N 并没有将.cpp
文件实际添加到项目中.
When adding a cpp file you want to use the Add new item icon. (top left with a gold star on it, hover over it to see the name) For some reason Ctrl+N does not actually add a .cpp
file to the project.
这篇关于“系统找不到指定的文件".运行C ++程序时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!