Skip to content

Errors and comments

Read · 1 of 4

The compiler checks your code first

If something isn't valid C, gcc refuses to build the program and tells you the line and what it expected. Nothing runs until every error is fixed.

The most common beginner mistakes: a missing ; at the end of a statement, a missing quote, and a forgotten #include <stdio.h>.

Comments are notes for people: everything after // on a line, or between /* and */, is ignored by the compiler.

Read this lesson as text

Read what the compiler tells you, fix the usual mistakes, and leave notes in your code.

The compiler checks your code first

If something isn't valid C, gcc refuses to build the program and tells you the line and what it expected. Nothing runs until every error is fixed.

The most common beginner mistakes: a missing ; at the end of a statement, a missing quote, and a forgotten #include <stdio.h>.

Comments are notes for people: everything after // on a line, or between /* and */, is ignored by the compiler.

Spot the mistake

#include <stdio.h>

int main() {
    printf("Ready\n")
    printf("Go!\n");
    return 0;
}

Which line has the mistake?

Show the answer

Line 4. Line 4 is missing its semicolon. The compiler often reports it on the next line, because that's where it noticed.

Exercise: Make it compile

This program won't compile. Run it, read the error, and fix it so it prints both lines.

Exercise: A missing quote

Fix the program so it prints C is fast.