[英]How c++ program read user input in VSCode while debugging
I'm trying to do debugging c/c++ program in vscode debug tab.我正在尝试在 vscode 调试选项卡中调试 c/c++ 程序。 Well, after setting some properties which is spread through google, it works well.
好吧,在设置了一些通过谷歌传播的属性后,它运行良好。 However, when I try to do debug with program containing "scanf" or "cin" which requires user input, it never receives any input from my keyboard.
但是,当我尝试使用包含需要用户输入的“scanf”或“cin”的程序进行调试时,它永远不会从我的键盘接收到任何输入。 How can I do so?
我该怎么做?
And what I found from google is that setting "externalConsole" value as true like this picture.我从谷歌上发现的是像这张图片一样将“externalConsole”值设置为真。
{
"version": "0.2.0",
"configurations": [
{
"name": "g++ - 활성 파일 빌드 및 디버그",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/Sort/test",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "lldb",
"preLaunchTask": "C/C++: g++ build active file"
}
]
}
However, if I change the value of externalConsole as true and try to debug program containing cin, there is no progress after the below picture.但是,如果我将 externalConsole 的值更改为 true 并尝试调试包含 cin 的程序,则在下图之后没有任何进展。
Even though I try to input the data in the external console(for example "asd"), it says "zsh:command not found asd".即使我尝试在外部控制台中输入数据(例如“asd”),它也会显示“zsh:command not found asd”。 How can I fix it for program to receive my input.
我该如何修复它以便程序接收我的输入。 HELP ME PLZ
请帮帮我
Code -> Preferences -> Settings
Code -> Preferences -> Settings
Follow these steps and you will be able to run your code on VSCode terminal and it would be possible to enter Input
按照这些步骤,您将能够在 VSCode 终端上运行您的代码,并且可以输入
Input
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.