简体   繁体   中英

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 :/

I've checked that I'm definitely using C++, and I've tried Win32 Console and CLR Console, neither seem to be working. 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). 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.

  2. Try "repairing" your installation of Visual Studio, via control panel->programs->"change" visual studio and then select "repair".

  3. Overly long project/solution/file names have also been documented to generate this error.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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