Reputation: 37172
I have created a project in Visual Studio 2008 Professional Edition.
This project contains one .cpp file for each assignment like this...
[-]Source Files
\
|-- 233.cpp
|-- test.cpp
And each file contains definition of main().
Action:CTRL+F5
Error 1 error LNK2005: _main already defined in 233.obj test.obj
Error 2 fatal error LNK1169: one or more multiply defined symbols found
How do I compile and see output of each file ?
Thanks.
Upvotes: 8
Views: 8296
Reputation: 10971
I guess in your situation your project consists of just one file. If you want to compile them separately then I suggest:
Upvotes: 3
Reputation: 67799
You can't have 2 functions called main() in a single project. What you should do is change the names of the functions, and then call them from a new main() function which would function as a menu.
If you make them separate projects, you can switch which one to run with Solution Properties -> Startup Project.
Upvotes: 12