About Main function | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

About Main function

I want to know about main function Is it user defined or predefined As we want to call a function to run it then how main function runs without calling

3rd Jan 2018, 4:38 AM
Ronak Pareek
Ronak Pareek - avatar
6 Answers
3rd Jan 2018, 5:13 AM
MR Programmer
MR Programmer - avatar
+ 3
Jamie can you explain in deep how operating system call main function
3rd Jan 2018, 5:07 AM
Ronak Pareek
Ronak Pareek - avatar
+ 2
Ronak, The convention in the c family is that the main class is the entry point in the program. An executable program is going to have many sections of code, you might have c, c++, assembly and others. it must have a starting address. when the c compiler sees "main" it tells the linker to use the stay off that class as the start of the program. For example, in Linux you can use readelf to see the value of the _start symbol for an elf file. HTH Juan
3rd Jan 2018, 6:19 AM
Juan-PDP
Juan-PDP - avatar
3rd Jan 2018, 5:05 AM
Hack Erer
Hack Erer - avatar
+ 1
@jamie no
3rd Jan 2018, 6:04 AM
Ronak Pareek
Ronak Pareek - avatar
0
When your program runs, the OS creat a process, and the main function is what the process doing. when the OS schedules to run the process, the main function is called.
3rd Jan 2018, 11:24 PM
pnalson