From the course: Debugging C Code

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Debugging your code manually

Debugging your code manually - C Tutorial

From the course: Debugging C Code

Start my 1-month free trial

Debugging your code manually

- When using a debugger seems like an ordeal, or you're just in a hurry, you can pull a few tricks to manually debug your code. The three simple things you can do are to talk through your code, output values at runtime, and generate progress messages. silly as it sounds, talking through your code really works. Do it out loud as if you're explaining your code to another programmer. So here goes in this program. The line 15 is a while loop and it's going to repeat as long as the value of variable x is less than 10, line 17 outputs to the value of variable X, but it adds one to it so that humans won't be confused and line 18 calls the whatever function and then the loop repeats at line 15 as long as the value of x is, oh, nowhere in here, am I modifying the value of variable x. It never increases, so the loop just keeps repeating. Wow, this example may seem silly, but I've caught dozens of bugs talking my way through…

Contents