Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

What is main() function is user defined function or predefined function ?

user-image
Question added by Amit kumar Gupta Amit
Date Posted: 2014/10/12

The main function is user implemented function whose prototype has been predefined by the compilers.

Ameer Khan
by Ameer Khan , Installation Specialist , Alghanim Industries

main() is a predefined function. when a program is set to compile. Compiler First looks for the main Function. Compiler starts compiling from main function

Falguni Desai
by Falguni Desai , Assistant Professor , Vadodara Institute of Engg., Vadodara, Gujarat

Main is Predefined/System function. When operating system handover the control of program, it looks for the main() function in the program. You can say it is a entry point of the your program. 

 

Prototype for the function is predefined for the function but the actual task of the main()  is defined by the user.

In C programming Language main(0 function is user implemented (user defined) whose declaration is fixed in the compiler. hence we can say that main() is predefined and user defined too because programmer has to write function's body.

Here is the complete article on it.

Is main function in C programming language predefined or user defined? 

Shafat Ahmad
by Shafat Ahmad , Trainer , Multichannel Educational Institute

When u compile and execute  a C program, the first thing your compiler or OS looks for in a program is the main() function..this is because all programs no matter how much complex start at the main()main() is a predefined function which can take only two arguments as:  main(argc, char *argv[ ]) argc = count of arguments

argv[ ] = is an array of strings or an array of char pointers

 

these are also known as Command Line Arguments

 

Moreover you usually do not use these arguments unless you want to supply arguments form the command line itself.

 

 

saurabh katiyar
by saurabh katiyar , software engineer , huawei technology india pvt ltd

main() is predefined function whose prototype is such that it can accept only two arguments and return integer. User can neither modify number of arguments it takes nor return type.

Maaligai Parai Karuppa samy P
by Maaligai Parai Karuppa samy P , Service & Embedded Engg , Indus Electronics, Chennai

Main Function is user derive function. only one main function in the program code.

More Questions Like This