Why is main() function is too important in c ?Why we use it? Working of main() function | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why is main() function is too important in c ?Why we use it? Working of main() function

Working of main() function

10th Aug 2022, 1:11 PM
Suraj Joshi
2 Answers
+ 2
Why does the English alphabet start with A? 🤷🏾‍♀️ That's just what the designer decided to do. It helps the compiler know when the program starts and when in finishes.
10th Aug 2022, 1:14 PM
Justice
Justice - avatar
+ 2
An executable program needs an entry point - an address that the operating system uses to start the program execution. It made sense to standardize the name of that entry point and to standardize the input and output parameters in order to have a common way to pass command line arguments and redirect input and output, as well as have a standard return data type so scripts could determine success or failure in a common way. Not all operating systems use main. Win32 uses WinMain, for instance. Some compilers let you override the entry point and specify a nonstandard one.
10th Aug 2022, 1:24 PM
Brian
Brian - avatar