Skip to main content

VS Code Debugger in C

VS Code Debugger

Visual Studio Code (VS Code) is a popular code editor that has a built-in debugger for C programs. The VS Code debugger provides a powerful and convenient tool for debugging C programs, making it easier to find and fix bugs and to understand how your code is executing.

With the debugger, you can set breakpoints, step through your code line by line, inspect variables, and analyze the call stack. This makes it easier to find and fix bugs in your code.

Steps to find and fix bugs

Launch configuration

  • To use the debugger in VS Code, you need to have a launch configuration that specifies how the debugger should start your program.

  • The launch configuration defines the executable that should be debugged, the arguments that should be passed to it, and the environment variables that should be set.

Start the debugger

  • Once you have a launch configuration, you can start the debugger by pressing the "F5" key or by clicking the "Start Debugging" button in the Debug panel.

  • When the debugger starts, it will run your program until it hits a breakpoint, or until you manually stop it.

Debug panel

  • While your program is running, you can use the Debug panel to inspect variables, set and remove breakpoints, step through your code, and view the call stack.

  • You can also use the Debug Console to run expressions and print values while your program is stopped at a breakpoint.