![How To Compile With Visual Studio How To Compile With Visual Studio](/uploads/1/2/5/6/125627660/708288328.png)
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.
Nov 26, 2018 - Compiling C/C++ programs with Microsoft's command-line compilers is possible, even if you don't have Visual Studio installed. You can do this. I am new to Visual Studio and I don't know how to compile a.cpp file. I made just a single.cpp file (ctr + n => Visual C++ => C++ file) and I tried to compile it. But in place where normally there's a compile button (like with c#) there is strange 'Attach' button.
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.