简体   繁体   English

Visual Studio 找不到我的 C++ hello world 文件

[英]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;
}

And then you could try to run this code:然后你可以尝试运行这段代码: 在此处输入图像描述

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.

相关问题 visual studio 2012你好世界c ++ - visual studio 2012 hello world c++ visual studio 2012 c ++ hello world - iostream无法正常工作 - visual studio 2012 c++ hello world - iostream not working Visual Studio 2010中的Hello World C ++ CUDA程序(Windows 7) - Hello World C++ CUDA Program in Visual Studio 2010 (Windows 7) 在 Visual Studio Code 中编译 Hello World C++ 代码 - Compiling Hello World C++ Code in Visual Studio Code 无法运行 Hello World C++ 程序 - Cannot run Hello World C++ program 在Visual Studio C ++ 2010中找不到或打开PDB文件 - Cannot find or open the PDB file in Visual Studio C++ 2010 为什么“ hello world” c ++程序会在Visual Studio 2015中引发这么多“ iosfwd”错误? - Why can a “hello world” c++ program raise so many “iosfwd” errors in visual studio 2015? 为什么Visual Studio生成的C ++“Hello World”项目看起来有点奇怪? - Why does the C++ “Hello World” project generated by Visual Studio look a little strange? 最小安装即可使用Microsoft Visual Studio运行C ++“ Hello World”程序? - Minimal installation to run a c++ “hello world” program using microsoft visual studio? C++ Hello world 在 Visual Studio 2019 中不断给我错误 - C++ Hello world keeps giving me errors in Visual Studio 2019
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM