what is the role of main() in cpp? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

what is the role of main() in cpp?

Please help me how important role is main function in cpp.

15th Aug 2020, 2:38 PM
Abhishek Kumar
Abhishek Kumar - avatar
3 Answers
+ 9
It's simply a entry point where actually exicution of the program begins.. irrespective of number of methods u included! The main function is called at program begining after initialization of the non-local objects with static storage duration. It is the designated entry point to a program that is executed in hosted environment (OS). The entry points to freestanding programs are implemented defined.
15th Aug 2020, 2:45 PM
chaithra Gowda
chaithra Gowda - avatar
+ 2
it is just an entry point to execute a program. os need to know where to start a program
15th Aug 2020, 2:45 PM
durian
durian - avatar
0
Abhishek Kumar This is called function. Any code inside its curly brackets {} will be executed. main() function is the starting point of any C++ program
20th Jun 2021, 5:54 PM
Sujuma
Sujuma - avatar