Fixing Errors

Sometimes your program works perfectly. However, usually you will have to fix errors before your program will run. This lesson will teach you how to fix errors.

I have SO MANY errors!

Don't worry! Sometimes if you have one error at the beginning of the program, the compiler will panic and tell you that you have many errors. You should start at the top of the program, and fix one error at a time. Usually, this will make the other errors go away by themself.

Warnings vs. Errors

When you compile your program, there are two ways the compiler will tell you if there is a problem:

Warnings - Your program will still compile, but it may crash when you try to run it.

Errors - Your program has a serious problem and cannot compile.

We will talk about both kinds of problems in this lesson, but it is good to know the difference.

Common errors and warnings

If you are having problems with an error, check if you are getting one of these messages:

error: expected ',' or ';'' before '*something*'

This error means you forgot a semicolon. The 'something' part is usually on the line AFTER the missing semicolon.

error: '*something*' undeclared (first use in this function)

This usually happens because you spelled something wrong. It means you are talking about a variable that you never created.

error: expected declaration or statement at end of input

This means you have an open brace "{" with no closing brace "}". Check your if-else statements, loops, etc. and try to find where there is a missing brace.

error: missing terminating " character

This means you started a string with " but didn't end it. Check your printf() functions and anywhere you talk about strings.