简体   繁体   English

C ++代码未在Visual Studio中运行

[英]C++ code not running in Visual Studio

I bought 'C++ For Dummies' around a week ago, and I'm trying to make a hello world program in Visual Studio, however the code doesn't work, it just says there are errors... The exact same code works fine in CodeBlocks, and I've searched Google for ages for an answer but there doesn't seem to be any :/ It's really confusing, it's almost like C++ is a completely different language to the one used in Code Blocks :/ 我大约一周前购买了“ C ++ For Dummies”,我试图在Visual Studio中制作一个hello world程序,但是该代码不起作用,它只是说有错误...完全相同的代码可以正常工作在CodeBlocks中,我搜索了很长时间的Google来找到答案,但似乎并没有找到它:/确实令人困惑,几乎就像C ++是一种与Code Blocks中使用的语言完全不同的语言:/

I've checked that I'm definitely using C++, and I've tried Win32 Console and CLR Console, neither seem to be working. 我已经检查过我肯定在使用C ++,并且尝试了Win32 Console和CLR Console,但似乎都没有用。 Would somebody be able to help? 有人可以帮忙吗? :/ :/

Code: 码:

#include <iostream> 
using namespace std; 

int main() 
{
    cout << "Hello world!" << endl;
    return 0; 
}

Error: 错误:

Unable to start program 'location of program' 无法启动程序程序位置”

This error can appear for a number of reasons. 出现此错误的原因有很多。

  1. If you have anti-virus installed, it may attempt to block any created .exe files (made when you built and compiled your program). 如果您安装了防病毒软件,它可能会尝试阻止任何创建的.exe文件(在构建和编译程序时创建)。 To test this, turn it off (temporarily), or add the location of your Visual Studio Project [your_drive]:\\[you]\\Documents\\Visual Studio 2010\\Projects to the "safe zone" or trusted location found in your anti-virus settings. 要对此进行测试,请将其关闭(暂时),或将Visual Studio项目[your_drive]:\\[you]\\Documents\\Visual Studio 2010\\Projects的位置添加到反安全目录中的“安全区域”或受信任位置病毒设置。

  2. Try "repairing" your installation of Visual Studio, via control panel->programs->"change" visual studio and then select "repair". 通过控制面板->程序->“更改” Visual Studio,尝试“修复” Visual Studio的安装,然后选择“修复”。

  3. Overly long project/solution/file names have also been documented to generate this error. 还记录了过长的项目/解决方案/文件名,以产生此错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM