VSCode Debugging

Show String in Detail

To see all the characters in a string s listed with their index, add a watch that looks like:

(char*) STRING_NAME, SIZE
  • STRING_NAME should be the name of the string you want to view.
  • SIZE is the number of chars to show. If you ask for more characters than are in the string, you will see extra memory that is not part of the string.

Here is an example of viewing 11 characters from the string s:

Watching

Show an Array

The debugger will show the contents of a statically allocated array when the array is viewed in its original context.

When an array is passed into another function, or when an array is allocated dynamically, the debugger doesn't know how many elements there are. So you usually will just be shown the first element. To see the rest, use the instructions below:

PC

Add a watch that looks like:

ARRAY_NAME, SIZE
  • ARRAY_NAME should be the name of the array you want to view.
  • SIZE is the number of elements to show. If you ask for more elements than there are in the array, the "extra" elements will be unpredictable values from nearby memory.

Here a watch is showing 3 elements from the array named array. Notice that the Locals pane just shows the first value from the array (5).

Watching

Mac

To see the contents of your array, go to the DEBUG CONSOLE panel. In the bottom, type:

parray SIZE ARRAY_NAME
  • SIZE is the number of elements to show. If you ask for more elements than there are in the array, the "extra" elements will be unpredictable values from nearby memory.
  • ARRAY_NAME should be the name of the array you want to view.

This shows what it should look like as you type in the command: