Sunday, 6 May 2012

ABOUT MAIN FUNCTION IN C LANGUAGE [What is void main(), int main(), char main(), main()], What is a function in C Language

Q. what is void main()

Q. what is int main()

Q. what is main() function in c Language

Ans :  The Main function : In many programming languages, the main function is where a program starts execution. It is responsible for the high-level organization of the program's functionality, and typically has access to the command arguments given to the program when it was executed.

The main function is generally the first programmer-written function run when a program starts, and is invoked directly from the system-specific initialization contained in crt0 or equivalent. However, some languages can execute user-written functions before main runs, such as the constructors of C++ global objects.

Example :
int main(void)
int main(int argc, char **argv)
int main(int argc, char *argv[])
int main()


Function prototype : A function prototype in C, Perl or C++ is a declaration of a function that omits the function body but does specify the function's return type, name, arity and argument types. While a function definition specifies what a function does, a function prototype can be thought of as specifying its interface.

In a prototype, argument names are optional, however, the type is necessary along with all modifiers (i.e. If it is a pointer or a const argument).




No comments:

Post a Comment