How To Use the Debugger in Visual Studio Code in C on a Mac

Something every developer will face is a bug, and what better way to get rid of bugs than with using a debugger?

What is a debugger?

A debugger is just a development tool that you can use to pause your program at a certain line of code. Then, you can step through your program line by line and track certain variables in your code that you’re interested in. You can also track the flow of your program.

The first time I was introduced to a debugger was in university. My professor was showing it to us and raving about it, but I didn’t see the value of it at the time. That’s because it was a command line interface debugger, and that seemed too complicated for me. I’d rather just put a printf statement there and see what the value is using a printf statement.

However, when I got into my job, we were using debuggers in our IDEs. The first time I really used a debugger was at my current job. We were using it in our Eclipse IDE and Visual Studio IDE. It was really helpful for me at the time because I had no experience in Java and C++. I was able to use the debugger to gain understanding of how the programming language worked and how the codebase I was given worked.

There are two main reasons why debuggers are really helpful.

  1. The first one is it allows you to look at the value of certain variables while the program is running. You can pause the program, look at the state of the program, and examine the variable values. This helps you understand the state of your program at a specific point in time.
  2. The second reason why debuggers are helpful is that they allow you to see the flow of your program. In my company, if we have a question about at what point does the program come to this part of the code, we would just put a breakpoint there, run the program, and see at what point the program gets to that line of code. Then, we can trace back to see what function called it and gain information about our program that way.

Debuggers are really helpful. It can be overwhelming and confusing at first to use a debugger, but when you get used to it, you realize that you can’t code or debug without it.

In this video, you’ll learn:
✅ how to set up the debugger in Visual Studio Code for C
✅ how to use the debugger
✅ how to diagnose and fix a bug with the debugger

Thank you for watching, and happy coding! 💻🧡
-Henrik