0

What is void main() in c++ especially main () function.

8th Dec 2017, 1:55 PM
Rahul
Rahul - avatar
3 Answers
+ 4
mainĀ is the default entry point of a C (and C++) program. The correct signature of the function is: intĀ main(int argc, char **argv, char **envp); and inĀ C++Ā it's treated as a special case, defined automatically as extern "C" to keep the symbol name free from name mangling TheĀ Main Function. InĀ C and C++, the "main"Ā functionĀ is treated the same as everyĀ function, it has a return type (and in some cases accepts inputs via parameters). The only difference is that theĀ main functionĀ is "called" by the operating system when the user runs the program ex:- int main(void) { Ā puts("Hello World!!"); /* prints Hello World!! */ return EXIT_SUCCESS; }
8th Dec 2017, 2:01 PM
GAWEN STEASY
GAWEN STEASY - avatar
+ 1
It's the infinite loop that contains your program while it's running. The entry and exit point of the program.
8th Dec 2017, 1:59 PM
AgentSmith