【问题标题】:Is it possible to print to a clear integrated terminal in VSCode是否可以在 VSCode 中打印到清晰的集成终端
【发布时间】:2021-08-29 07:58:48
【问题描述】:

我希望我的程序的输出打印在一个空终端上。即,而不是,

PS C:\Stuff\More Stuff>  & 'c:\Users\user\.vscode\extensions\ms-vscode.cpptools-1.4.1\debugAdapters\bin\WindowsDebugLauncher.exe' '--stdin=Microsoft-MIEngine-In-w1d2d2zg.skd' '--stdout=Microsoft-MIEngine-Out-2q3w4dx4.xne' '--stderr=Microsoft-MIEngine-Error-sr0qr1un.pod' '--pid=Microsoft-MIEngine-Pid-zddzumbv.aaf' '--dbgExe=C:\Program Files\CodeBlocks\TDM-GCC-64\bin\gdb.exe' '--interpreter=mi'
Hello from my program

我想要,

Hello from my program

这是我的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": "g++.exe - Build and debug active file",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${fileDirname}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "miDebuggerPath": "C:\\Program Files\\CodeBlocks\\TDM-GCC-64\\bin\\gdb.exe",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "C/C++: g++.exe build active file"
        }
}

那么,有没有办法将程序输出到空终端?

编辑:我发现了一个类似的问题here,但发布的解决方案对我不起作用。它说,“不允许使用属性控制台”。我正在使用 f5 调试器来运行我的 C++ 程序。我发现了一些其他类似的问题,但他们没有答案。

【问题讨论】:

  • 也许这个设置会有所帮助:stackoverflow.com/a/66804862/836330
  • @Mark 不,它没有帮助,该设置只清除以前的输出,我希望 vscode 运行的命令不显示,或者至少,我的程序的输出单独显示在另一个综合终端。谢谢你:)

标签: visual-studio-code terminal settings vscode-settings vscode-debugger


【解决方案1】:

目前,我能找到的最佳工作解决方案是在程序开始时运行以下命令。

int main()
{
    cout << "\033[2J\033[1;1H";

    /*rest of the code here*/
}

这会在执行实际程序之前清除终端。这也将清除以前运行的任何输出。我希望有我以前的输出。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-03-09
    • 2019-06-12
    • 1970-01-01
    • 2019-10-30
    • 2019-12-27
    • 2021-04-19
    • 2023-01-03
    • 2018-02-08
    相关资源
    最近更新 更多