+ 1

Can anyone help me, what is going on in here ?

#include <iostream> using namespace std; int main() { cout << "Hello world!"; return 0; } Why our main() function's data type is integer? and why we return "0" ?, I'm new for C++ programming.. Thank you :)

3rd Oct 2016, 7:18 AM
Nasser
Nasser - avatar
1 ответ
+ 1
This is a very frequent question. The return value of the program can be used by another program that launched it. A return value of 0 means no error, a non-zero one means any error of your choosing. You can then do things differently in the main program depending on that error code. It is unused most of the time, so you can just ignore it and just return 0.
3rd Oct 2016, 9:24 AM
Zen
Zen - avatar