3. Integrated Development Environment

Syntax Errors

Without any doubt, when writing programs, you will make mistakes. In fact, there will be lots of mistakes. To prepare you for this possible shock, let us intentionally insert one of the simplest mistakes into our program.

Change the last statement of the program into:

    cout << "While I catch my fish" << endl

In other words, delete the semicolon at the end of the statement.

Try to execute the program now.

The dialogue will appear informing you about the existence of errors in the program. Just press the Enter key there (or click on the No button).

The information on errors will be displayed in the window at the bottom of the IDE:

Error window screenshot

It appears that this error is identified well by the compiler. But, that will always be the case. The compiler will do its best to try to identify the mistake. Still, under certain circumstances, it might report an error in the line below the line containing the actual error, and it might misreport the description of the error.

This kind of error where the text of the program does not comply with the rules of the language is known as a syntax error.

If you double click on the error description in the Error List window, the cursor will move approximately to the place in the text of the program where the error was detected, and the line in question will be marked by a small symbol on the left side of the source code.

All the syntax errors will be found when the compiler attempts to translate the program. The program containing syntax errors cannot be translated, thus it cannot be executed until all the syntax errors are corrected.