Read a Program
You have edited the lines inside main while leaving the surrounding code alone. Now connect those familiar output statements to the rest of the file: the header makes library names available, and main groups the instructions that run.
#include <iostream>
int main() {
std::cout << "Doors open" << "\n";
return 0;
}
The line before main
#include <iostream> makes the standard input/output declarations available, including std::cout. A header supplies declarations that help the compiler understand names used by your program. This include line is not an ordinary statement and has no semicolon.
The std:: prefix says that cout belongs to the standard library's namespace, a named group that keeps library names organized. Keep that prefix when you use cout in this course.
Where execution begins
main is the program's entry function. A function groups instructions under a name; later you will write your own. In int main(), int describes the integer status returned when this function finishes. The parentheses are part of the function notation. Here they are empty.
The opening { and closing } enclose the function's body. Indenting the lines inside makes that boundary easier for people to see. The braces, rather than the indentation, establish the boundary for C++.
std::cout << "Doors open" << "\n"; is a statement that produces output. return 0; ends main and reports successful completion. It does not print the number zero.
Read an error as a clue
The compiler checks source before running it. A missing quote, unknown name, or missing semicolon can prevent execution. Start with the first reported location and check that line and the preceding line; the compiler may notice a mistake just after it occurred. Correct one issue, then run again.
A program can also compile and still print the wrong message. Compilation checks whether the code is valid; comparing output checks whether it does what you intended. Both habits matter.
The diagram separates editing source, compiling it, and running the result. It uses a different greeting, Ready, from the Doors open example above.
The output statement shown belongs inside main in a complete source file. The browser builds that source before running the executable; Ready is program output, not a compiler message.