I want to ask can we have multiple main() method in one project. Because I want to create multiple main() method for different projects in 1 solution. Because right now, everytime I want to create new main() method, I must create it inside different solution coz there'll be error...
With this method, to use main 2 you would uncomment it and comment out main 1. The method in my previous post is similar to this except the "commenting out one and uncommenting the other" is done for you automatically by the preprocessor.
If the compiler sees more than one main() method, your program won't compile. So, yes you can have only one int main{...} in your program and thus only one "main" can run.
Using my last post as an example, if you compile and run it, it will show "This is main 1!", meaning that main 1 was run.
If on the other hand, you want main 2 to run, you would comment out main 1 and uncomment main 2. You would need to compile and run it again. This time it will show "This is main 2!", showing that the second main is running. You need one commented because the compiler would complain that there are two mains.