I am able to run the cpp file if create a project and build the solution but when i add another file cpp there is a error as there can be only one main function in a project.
I don't want to create a project just execute singel individual files in Visual Studio; I can executehi individual files in Visual Studio Code.. How do I do this Visual Studio.(IDE)
CodePudding user response:
You don't run source "C files"; you run executable files. These are built from source files through the compilation and linking process. A VS project represents the sequence of steps needed to build a single compilation product (executable, library, etc).
So if you have two source files, each of which separately builds two executables, that means you want two projects.
CodePudding user response:
If you wish to compile individual files on VS you can simply click "terminal" at the top of the application and then "Run Build Task". After running the build task with your selected compiler it will create an executable that you can test/run.
for example
I have a file open called main.cpp
After selecting "Terminal" and then "Run Build Task" and selecting the compiler "gcc, g " the compiler will produce an executable called main.exe