I am not sure you know what the process of "debugging" means.
First thing to understand is the difference between compiling & debugging.
Compilation is when the computer converts your code into a binary executable that the OS can execute. If there are errors in the code, the compiler reports these. This does not find runtime or logical error and is not debugging.
Debugging is the process of finding errors, by tracking the value of variables to see where they cause a problem. There are a few ways to do this:
1. Write down the values on paper (yes paper), keeping track of the program logic, and seeing how they change. This is probably the hardest way.
2. Put lots of print (cout or printf) statements, to see how the values change. This is easier.
3. Use a debugging program, either one built in to the IDE, or a command line one. The IDE version is easiest, but debugging from the cmd line is a very good skill to have.
With IDE debuggers, you can set breakpoints, have a watch list of variable values, step through the code 1 line at a time. This is the method of debugging.
The worst kind of problem to have is a logical error. This is where the logic is just plain wrong from the start - no amount of debugging will solve this. An example of logical error might be:
Apples + Bananas = how many Oranges? |
Usually logic errors are much more subtle than this, perhaps a better example might be using the wrong trig function to calculate something.
Hope all goes well.