【发布时间】:2019-03-01 09:28:17
【问题描述】:
嗨,
我对 VS Code 上的 C++ 编程非常陌生,所以我有几个问题要问。
我的软件规格:
- Linux,64 位,深度 15.9
- VS 代码 1.31.1
- G++ - 8,GDB 7.12
- 使用的扩展:C/C++ IntelliSense、调试和 Microsoft 的代码浏览
二维数组的 C++ 漂亮打印
我必须在编程时调试很多多维数组,因此我想知道如何在“变量”窗口(“观察”窗口也可以)中查看二维数组的方法,在矩阵的形式。
目前我的变量的窗口看起来像这样
我希望它类似于
我知道可以使用here 发布的方法查看二维数组,但我想在 VSCode 的调试选项卡中查看它。有什么漂亮的打印方法或代码可以帮助我实现目标吗?
停止调试过程时终端上的随机消息
在停止 C++ 的调试过程后,终端上会出现某种消息。这就是它的样子 -
我从打开外部终端进行调试切换到使用内置终端,因为在我停止调试过程后,会显示上述消息并且终端不会自动退出,所以我必须手动关闭终端。在 Windows 上情况并非如此,终端会在调试后自动退出。有什么方法可以防止此消息(它在调试完成或停止后出现)?
我想用外部终端调试,请问有没有办法去掉这个错误信息,或者调试结束后自动退出?
这些是我的 *.json 文件
c_cpp_properties.json
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"compilerPath": "/usr/bin/g++-8",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "gcc-x64"
}
],
"version": 4
}
launch.json
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/a.out",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"setupCommands": [
{
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
tasks.json
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"_runner": "terminal",
"tasks": [
{
"label": "Build",
"type": "shell",
"command": "g++-8",
"args": [
"-g",
"${file}"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
真的很感激任何帮助!
【问题讨论】:
标签: c++ arrays visual-studio-code vscode-debugger