jroes
jroes

Reputation: 33

Visual Studio 2019 is not running other .cpp files

enter image description here

New to VS and C++. I'm trying to run code for source file "test2.cpp." However, every time I run the program, VS always runs "Simple-letter-with-ASCII-number.cpp."

I'm on the "test2.cpp" window, but the file never runs. I need assistance in running "test2.cpp" and not "Simple-letter-with-ASCII-number.cpp," without deleting any .cpp files, if possible.

Upvotes: 0

Views: 858

Answers (2)

blackdrumb
blackdrumb

Reputation: 320

Your project will call main() when it runs. When you said “differently labeled main()” I am assuming you changed a main() to test2main(). Just change the main function you want to run to be main() and your program should run when you recompile.

Upvotes: 2

rustyx
rustyx

Reputation: 85361

The screenshot looks like Visual Studio 2019, not Visual Studio Code.

Both .cpp files are part of the project.

If you want to keep only test2.cpp, then remove the other from the project (right-click on it, select "Remove").

Then build (Ctrl-Shift-B) and run (F5).

Upvotes: 1

Related Questions