Lab: debugging C with VS Code & mantis

In this lab, you'll practice using VS Code's C debugger.

The images in this lab are from macOS, because my current laptop is a Mac. The Windows and Linux versions of VS Code look similar to this, but not identical, so you should adapt accordingly.

What's a debugger?

A debugger is a tool designed to help you debug your programs (duh). Debuggers tend to have dozens of sophisticated features, but the heart of the matter for most programmers is this: a debugger allows you to run your program one line at a time, enabling you to examine your variables along the way. If you can watch your variables evolve one slow line of code at a time, you can usually track down your errors.

Phase 1: setting breakpoints and looking at variables

What about command-line arguments?

Get a copy of character_counter.c into your mantis working directory. Note that this program requires a command-line argument. How can we provide that argument to the debugger?

A few more things to try

That's it!

There's lots more to learn about using a debugger, but this should give you a good start. Keep practicing!