[英]Visual Studio cannot find my C++ hello world file
#include <iostream>
int main()
{
std::cout << "Hello World" << endl;
return 0;
}
When I try to run this code, this message keeps popping up even though I copied and pasted straight from online.当我尝试运行此代码时,即使我直接从网上复制和粘贴,此消息也会不断弹出。 There are no build errors either.
也没有构建错误。 Here's the error message
这是错误消息
Nothing wrong with your code.你的代码没有错。 Could be your antivirus deleting the exe before visual studio can start it.
可能是您的防病毒软件在 Visual Studio 启动之前删除了 exe。 Try disabling your antivirus and run from VS again.
尝试禁用您的防病毒软件并再次从 VS 运行。
If not antivirus, then something else is deleting it.如果不是防病毒软件,那么其他东西正在删除它。
Check if the exe shown in the path in your image is really there or not.检查图像路径中显示的 exe 是否真的存在。
If you click Build -> Build Solution, you will get an error:如果点击 Build -> Build Solution,会报错:
error C2065: 'endl': undeclared identifier.
错误 C2065:“endl”:未声明的标识符。
I suggest you should try to use std::endl
我建议你应该尝试使用
std::endl
Here is the code:这是代码:
#include <iostream>
int main()
{
std::cout << "Hello World" << std::endl;
return 0;
}
I added the file from the new file option not directly from the source file once I created the c++ project.创建 c++ 项目后,我从新文件选项中添加了文件,而不是直接从源文件中添加。
that error means that the.exe file is most likely still running.该错误意味着 .exe 文件很可能仍在运行。 it may be that you closed it trough the "X" button, but the VS debugger is still running, so try clicking on the red square to stop it or go in your task manager and manually kill the process.
可能是您通过“X”按钮关闭了它,但 VS 调试器仍在运行,因此请尝试单击红色方块停止它或在任务管理器中单击 go 并手动终止该进程。
it may also be that the exe is opened by another process such as a hex editor which is denying further execution access to the file, but i have had this issue personally before and the fix above worked.也可能是 exe 是由另一个进程(例如十六进制编辑器)打开的,该进程拒绝进一步执行对文件的访问,但我之前个人遇到过这个问题,并且上面的修复工作有效。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.