Reputation: 15860
I recently installed Visual Studio 2013. I can create a new project (Visual C++), but the error I have to come across is that I cannot run the app. Here is the code that I'm trying to run on Visual Studio 2013.
#include <iostream>
using namespace std;
int main() {
cout << "Hello World";
return 0;
}
I am sure this code would run, and will output hello world, but in Visual Studio it gives me issues, saying:
Values cannot be null,
Parameter name: solutionDirectory.
What am I missing here?
Here is an image for this:
Upvotes: 28
Views: 146600
Reputation: 1
You may be forgetting something. Before #include <iostream>
, write #include <stdafx.h>
and maybe that will help. Then, when you are done writing, click test, than click output from build, then when it is done processing/compiling, press Ctrl+F5 to open the Command Prompt and it should have the output and "press any key to continue."
Upvotes: -2
Reputation: 1553
In Visual Studio, you can't just open a .cpp
file and expect it to run. You must create a project first, or open the .cpp in some existing project.
In your case, there is no project, so there is no project to build.
Go to File --> New --> Project --> Visual C++ --> Win32 Console Application
. You can uncheck "create a directory for solution". On the next page, be sure to check "Empty project".
Then, You can add .cpp
files you created outside the Visual Studio by right clicking in the Solution explorer
on folder icon "Source" and Add->Existing Item.
Obviously You can create new .cpp this way too (Add --> New). The .cpp file will be created in your project directory.
Then you can press ctrl+F5 to compile without debugging and can see output on console window.
Upvotes: 55