【发布时间】:2021-02-08 09:20:01
【问题描述】:
我在VSCode中调试如下代码:
int main() {
char arr1[] = {'t', 'e', 's', 't', '\0'};
char arr2[] = "test";
int arr3[] = {1, 2, 3};
double arr4[] = {1.1, 2.2, 3.3};
}
前两个数组的元素显示为:
116 '<error reading variable>
101 '<error reading variable>
115 '<error reading variable>
116 '<error reading variable>
0 '<error reading variable>
而最后两个数组的元素显示数字的实际值。
launch.json文件的内容是:
{
"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:\\MinGW\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: g++.exe build active file"
}
]
}
我该怎么做才能让前两个数组显示数组中的字符?
【问题讨论】:
标签: c++ debugging visual-studio-code vscode-debugger