astidham2003
astidham2003

Reputation: 964

Incorrect main method running in visual studio

I'm trying to do some tutorial C++ programs to familiarize myself with the language. I'm using Visual Studio 2010. I have a Visual Studio solution with two projects - I'll just call them projectA and projectB. Each project has a source file with its own main method. However, when I try to run the program in projectB, the program in projectA runs instead. I'm coming from an Eclipse IDE where projects separate the programs. I've some msdn articles on solutions and projects, but I haven't seen anything about being unable to have multiple source files with main methods in them. Can someone help to clarify the Visual Studio Solution/Project structure for me, please.

Upvotes: 0

Views: 1059

Answers (4)

Vlad from Moscow
Vlad from Moscow

Reputation: 310990

Either you can right click on the project in the Project Explorer and select Set As StartUp Project or you can use meny item Project and also select Set StartUp Project.

Upvotes: 0

GMasucci
GMasucci

Reputation: 2892

I hope this is a nice simple fix: if you look at your solution and have both projects open, you should be able to right click one of them and set it as default (Set as Startup Project), (which sounds like at the moment is set to projectA).

I have highlighted the relevant option in the menu picture: enter image description here

Upvotes: 0

Csaba Toth
Csaba Toth

Reputation: 10699

You have to right click on the project and "Set as Startup Project" to tell Visual Studio which project you want to actually run.

Upvotes: 1

benjymous
benjymous

Reputation: 2122

Right click on the project you want to run, and select Set as StartUp Project

Upvotes: 1

Related Questions