The simplest C++ program consists of only 8 characters:
int main()
{
return 0;
}
Explain each character in the program:
int main:
the
main function that starts a programme is always called
main
. The word
int
indicates the type of value to be returned (integer).
return 0:
when your
main function terminates, it returns a status code to the operating system, which is checked to determine if your application was functioning normally. A value of 0 indicates "all ok, normal output", any other value is usually an error code.
Moreover, the C++ programming language distinguishes between capital and small letters.
()
- Empty brackets mean that main has no arguments.
{}
- Curly brackets indicate the beginning and end of the main program. All actions that must be performed are written inside curly brackets.
What does our program do?
Since there is nothing inside the curly braces, our program does nothing, it simply complies with the rules of the C++ language, it can be compiled and an exe-file can be obtained - an executable file that can be launched for execution.