3
$\begingroup$

As the functions are of 2 type:
1.Pre-defined/library functions,
2.User defined functions.

What type of function is main() function?

This doubt comes in my mind while writing a program we define the main() function as we do the others.

Please help!!!

$\endgroup$
  • $\begingroup$ Emm user-defined?.. C++ program should have main function when linker links it to the binary code which starts executing the program calling this function. It was not the only way long time ago, not sure how it works nowadays. $\endgroup$ – Eugene Mar 11 '17 at 7:15
  • $\begingroup$ How is this a computer science question? $\endgroup$ – Raphael Mar 11 '17 at 10:13
  • 1
    $\begingroup$ @Raphael, then tell me to which subject does this question belongs? $\endgroup$ – Harsh Kumar Mar 13 '17 at 5:14
  • 1
    $\begingroup$ Depends. Where have you found this (very rough) classification? To me, this reads like a programming question. $\endgroup$ – Raphael Mar 13 '17 at 7:36
  • $\begingroup$ Ohhh! I beg your pardon. For giving the tag as functional-programming $\endgroup$ – Harsh Kumar Mar 13 '17 at 13:40
3
$\begingroup$

Library functions are functions that somebody else coded, and are available for use.

User-defined functions are functions that the user defines. This is the case of the C/C++ main().

You can think of main() as a placeholder or hook. The user supplies it, but the standard library knows to call it after initializing itself.

| cite | improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.