Predefined Functions in C Programming Langauge

Rumman Ansari   Software Engineer   2019-03-31   9527 Share
☰ Table of Contents

Table of Content:


Is main() function predefined or user defined?

This is an interesting question, Is main() function in c programming language predefined or user defined?, in this article we will explain you what is main() in c programming language.

main() function is a user defined, body of the function is defined by the programmer or we can say main() is programmer/user implemented function, whose prototype is predefined in the compiler.
Hence we can say that main() in c programming is user defined as well as predefined because it's prototype is predefined.

Definition of main()

main() is a system (compiler) declared function whose defined by the user, which is invoked automatically by the operating system when program is being executed.

Use of main()

Its first function or entry point of the program from where program start executed, program’s execution starts from the main. So main is an important function in c , c++ programming language.

Prototype of main()

Some of the main() prototype’s given below:

void main(void)
{
    /* Declaration part */
    /* Executable part */
}

No return type and no argument. 

int main(void)
{
    /* Declaration part */
    /* Executable part */
}

Integer type return type with no argument. 

int main(int argc, char *argv[])
{
    /* Declaration part */
    /* Executable part */
}
int main(int agrc, char **argv)
{
    /* Declaration part */
    /* Executable part */
}