c++ - C++ 终端在 Visual Studio 代码中不起作用
问题描述
我有一个 C++ 程序。这个程序不工作。我改为"externalConsole": false
,"externalConsole": true
它可以工作,它给了我控制台。但我想与"externalConsole": false
. 有没有办法做到这一点?相关输出如下。
程序 (asd.cpp)
#include <iostream>
using namespace std;
int main()
{
int x = 1525, z;
cout << "x number is " << x << endl;
cin >> z;
cout << "z number 2 is " << z << endl;
getchar();
}
启动.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}/asd.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "C:/MinGW/bin/gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
终端
Windows PowerShell
Try the new cross-platform PowerShell https://aka.ms/pscore6
PS C:\Users\hakan\projects\onecpp> & 'c:\Users\hakan\.vscode\extensions\ms-vscode.cpptools-1.3.0-insiders4\debugAdapters\bin\WindowsDebugLauncher.exe' '--stdin=Microsoft-MIEngine-In-emhvpzpo.syb' '--stdout=Microsoft-MIEngine-Out-dht4nkur.p5d' '--stderr=Microsoft-MIEngine-Error-cpkcr2pw.mzq' '--pid=Microsoft-MIEngine-Pid-v2fsb4cd.no1' '--dbgExe=C:/MinGW/bin/gdb.exe' '--interpreter=mi'
PS C:\Users\hakan\projects\onecpp>
调试控制台
=thread-group-added,id="i1"
GNU gdb (GDB) 7.6.1
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "mingw32".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Warning: Debuggee TargetArchitecture not detected, assuming x86_64.
=cmd-param-changed,param="pagination",value="off"
=cmd-param-changed,param="args",value="2>CON 1>CON <CON"
[New Thread 9284.0x16f4]
x number is 1525
z number 2 is 1013
The program 'C:\Users\hakan\projects\onecpp\asd.exe' has exited with code 0 (0x00000000).
我做了一个程序来输入数据,我不能输入数据,它写了 1013。
构建工作:Build finished successfully.
解决方案
该设置"externalConsole": false
已弃用。请尝试使用"console": "integratedTerminal"
最新版本的 Visual Studio Code。对我来说,集成终端中的控制台输入可以正常工作。
推荐阅读
- javascript - 递归 JavaScript 函数导致“范围错误:超出最大调用堆栈大小”
- minimization - 限制负对数似然最小化的参数
- java - 如何在 JPanel 上绘制矩形?
- c# - 使用枚举的 JsonConvert.SerializeObject 无法正确检索 EnumMember 属性值
- c++ - C++ 自定义比较函子
- php - 如何使用 PHP 获取平面 JSON 文件并构建分层菜单
- html - Bootstrap flexbox 自对齐类无法正常工作
- javascript - Emscripten:null 终止 Uint8Array?
- angular - 在 Angular 中运行“npm run dev:ssr”时出错
- r - 解释分箱散点图 (R) 并计算均值的方差