VSCode <error reading variable> when viewing array elements during debugging

  c++, debugging, visual-studio-code, vscode-debugger

I am debugging the following code in VSCode:

int main() {
    char arr1[] = {'t', 'e', 's', 't', '{$content}'};
    char arr2[] = "test";
    int arr3[] = {1, 2, 3};
    double arr4[] = {1.1, 2.2, 3.3};
}

The elements of the first two arrays show as:

116 '<error reading variable>
101 '<error reading variable>
115 '<error reading variable>
116 '<error reading variable>
0 '<error reading variable>

Whereas the elements of the last two arrays show the actual values of the numbers.

The contents of the launch.json file are:

{

    "version": "0.2.0",
    "configurations": [
        {
            "name": "g++.exe - Build and debug active file",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}${fileBasenameNoExtension}.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": true,
            "MIMode": "gdb",
            "miDebuggerPath": "C:MinGWbingdb.exe",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "C/C++: g++.exe build active file"
        }
    ]
}

What can I do so that the first two arrays show the characters in the array?

Source: Windows Questions C++

LEAVE A COMMENT