can we use more than 1 main fuction in a program....if yes how and how compiler work | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

can we use more than 1 main fuction in a program....if yes how and how compiler work

10th Jul 2016, 3:44 PM
Uday singh Solanki
Uday singh Solanki - avatar
7 Answers
+ 1
Also, why would someone use multiple main functions? I would consider this a "bad practice" as it is confusing which of the main functions is being called from the operating system. I would assume that this is unnecessarily confusing to many other developers, too, with no gain I can see.
10th Jul 2016, 8:15 PM
Stefan
Stefan - avatar
+ 1
No as compiler start compiling the program form main() and if there are two main() then compiler gets confused and also program may not run.
5th Dec 2016, 7:40 AM
Dharm Vashisth
Dharm Vashisth - avatar
0
yes
10th Jul 2016, 4:13 PM
aditya
aditya - avatar
0
we can use
10th Jul 2016, 4:13 PM
Bhavuk Mittal
Bhavuk Mittal - avatar
0
ya we can do that
10th Jul 2016, 4:44 PM
Pratim Majumder
Pratim Majumder - avatar
0
sure
10th Jul 2016, 5:04 PM
Abbas Tailor
0
If you can define multiple main functions, which one will be called by the operating system to start the program?
10th Jul 2016, 6:44 PM
Stefan
Stefan - avatar