+ 13
What is the purpose of int main() in C++
I just started learning C++ and I don't really understands what is the main function, what does it do and why do we need it? Can't we just have different functions, like in Python?
4 Answers
+ 6
Main() is the main function,
everytime your program gets executed, the main() function is called.
You can call other functions too, but you have to call them inside the main().
Also make sure to return 0 at the end of the main(), this will indicate that the program has finished successfuly.
+ 5
Basicly when your program starts running, the first thing it looks for is the programs main function (so it knows where to start execution).
+ 2
The main function is where the compiler begins the execution of a program.It can be given a type into or it can be void. It is void when the function doesn't return anything
+ 1
Pardon me, as I want to ask some Questions. My students asked me why it is int main() not something like void main()? I dont know how to answer tho. Any explanation?