Goal: Students run into many of the same errors. This is a quick reference page to help you find the problem by learning to understand the error message.
Illegal symbol: x
If you have an illegal symbol,
x is probably a
typo of an actual function.
You are probably calling an stdio
function by the wrong name. Some examples of typos:
fscan, print, etc.
Illegal new line in string constant
You have a new line (an actual return, not a "\n") in a string. Find the first line that has this problem. The problem is probably that you did not terminate a string constant where you expected to. Use Emacs' syntax highlighting and formatting to help identify where your problem is.
These are tricky: they usually mean that you forgot a semicolon at the end of a statement or you have misaligned braces. Find the first line in the code that has the parse error. Look above that line and check if you are missing a semicolon and make sure that you have matching braces.
This one had me held up for awhile:
function designator is not of function type
First, try compiling with gcc to see if you get a different error.
The problem is that you have a function and a variable with the same name. Tricky one, huh?
These are memory access problems. They are often caused by errors reading input or printing output or accessing an array at an index that is out of bounds. Things to look for with input:
scanfarguments include variables with the
scanfargument match the datatype of the specification format?
Things to look for with output:
Things to look for with arrays:
When I look at your code, I look for a few things:
Some more suggestions:
Your code is usually made up of several pieces. For example, you may read in input, process the input, then print the output. Look at each of these sections independently, and make sure that each section works as you expect
When you are having trouble and you can't think through the code, you can try adding print statements. (Make sure your print statements are correct!) You can use the print statements to figure out how far you're getting in your code so that you can determine where a segmentation fault occurs.
Other common problems and solutions? Email and I'll share your hints on this page.