In one portion of the salmon cookies lab I had a syntax error, by forgetting to add an ‘s’ to the end of “cookie.” But another portion of the code was more difficult to fix when I used two different phrases for something I wanted to be the same function.
Just like everything else, practice with coding will provide the repitition needed to know. Becoming more familiar with the debugging codes will help to locate the issue quicker, and the more practice with the code itself will help to be more accurate when creating the code in the first place.
It is similar to how spell check will watch out for spelling and grammatical errors in one’s writing. The debugging tool watches out for syntaxical and logical errors in the code. However, neither one is fool proof in the right or wrong direction, so it’s best to try to know what you’re doing instead of just relying on the tool to fix the mistake.
A breakpoint is a little stopping point you can put into the code to have it run small blocks in isolation, in cases where there are issues in the code it is a great technique to break the problem into bite size pieces.
Modern debuggers contain one more debugging information window that can be very useful in debugging your program, and that is the call stack window.
When your program calls a function, you already know that it bookmarks the current location, makes the function call, and then returns. How does it know where to return to? The answer is that it keeps track in the call stack.
The call stack is a list of all the active functions that have been called to get to the current point of execution. The call stack includes an entry for each function called, as well as which line of code will be returned to when the function returns. Whenever a new function is called, that function is added to the top of the call stack. When the current function returns to the caller, it is removed from the top of the call stack, and control returns to the function just below it.
https://www.learncpp.com/cpp-tutorial/using-an-integrated-debugger-the-call-stack/#:~:text=The%20call%20stack%20is%20a,to%20when%20the%20function%20returns.