1

I have been following tutorials which have me download and unzip projects which contain .sln files for me to open. Following them this way is pretty easy. However, I want to be able to download a single .cpp file and run it without creating a project. I just want to get straight to into it. In Code::Blocks, setting this up is easy to figure out. For some reason, I can figure it out in Visual Studio.

JimGordon
  • 385
  • 3
  • 8
  • 4
    Your title and body says "Visual Studio", but I just noticed that you included the [[tag:visual-studio-code]] tag. Can you please clarify which you're using, Visual Studio or Visual Studio Code? They are different products. – Cody Gray - on strike Nov 22 '20 at 05:28
  • 1
    My habit is to maintain a CppScratchwork project with a single .cpp (and maybe a couple other header and source ones or a foo.txt input file) and copy/paste to that when I just want to run a small code sample from VS. – Nathan Pierson Nov 22 '20 at 05:31
  • 1
    By *"I want to be able to download a single .cpp file and run it without creating a project."* do you mean *"I want to be able to download a single .cpp file and run it **from within Visual Studio** without creating a project."*? The difference is significant (for one-file programs, I have a tendency to not use an IDE because I don't want to create a project for the one file). – JaMiT Nov 22 '20 at 05:43

2 Answers2

4

I want to be able to download a single .cpp file and run it without creating a project.

You cannot. Visual Studio does not support this. A project is always required, even if it only contains a single source code (.cpp) file.

You can, however, run a single .cpp source file through Microsoft's C++ compiler on the command line (cl.exe), and then execute it. But this doesn't involve anything about the Visual Studio IDE.

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
-3

if you have the source code, you could make a .cpp file by right-clicking and adding one and then ctrl+s then f5 and it might run... Idk.