Home Forums Programming help with codes, can’t spot mistakes Reply To: help with codes, can’t spot mistakes


Compilers can’t know what comes next so they choose a message that seems most likely and which would work. You as a programmer have to learn to get familiar with the messages and a history of reasons why that error might show up. It might be worth keeping a text file / database of all the errors you have and the messages you got at the time.

Usually all you should need to do is check the line number and have a look closely around there in your code for mistakes (related or unrelated to the message). If badly stuck try (sensibly so that the program should still compile) commenting out the line of code and see if the error goes away – that at least tells you are on the correct line.

Beware that missing ; or } can cause errors to show up in completely unrelated locations in the file as can hidden characters like and unfinished `. Also remember that you can always compile the .c / .cpp file on it’s own – any compilation error will be related to just the file and what it includes – not other unrelated files in the same project.