添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement . We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I couldn't use cin command in c++ when debugging because we can't input something in debug console. After that I saw so many people said to use "externalconsole": true but after that, the console closes as soon as the program finishes execution.
I heard we can use a cin command at the end of the CPP file but it is very annoying that we always have to write cin command at the end. So how can I fix it? Is there any way to use integrated terminal instead of debug console? Btw I am talking about Cygwin Gcc

@WardenGnaw This doesn't work in macOS, at least for me, I always have to use "externalConsole": true for debugging programs that use std::cin.
Also, it's posible to use iTerm.app as the default terminal instead of Terminal.app? I have changed this setting "terminal.external.osxExec": "iTerm.app" but doesn't seem to work in debugging.

@lucasaf04 The macOS issue is tracked at #5079 .

This issue here was with Cygwin, and it is used for Windows and externalConsole is possible in this scenario.

Also, it's posible to use iTerm.app as the default terminal instead of Terminal.app?

The externalConsole is not controlled by VS Code and that option is not propagated to the debugger. Because iTerm.app is not a default application, it is currently hard coded to use Terminal.app .

See https://github.com/microsoft/MIEngine/blob/9072ed87a5d9a14303aebbb074664cfbab88fc19/src/MICore/osxlaunchhelper.scpt#L11

This issue here was with Cygwin, and it is used for Windows and externalConsole is possible in this scenario.

Ohh. Sorry. So I would never be able to debug “cin programs” on macOS using integrated terminal?

Hope #5079 gets fixed soon.

Nope it is not working still. This is my cpp code:

#include <iostream> int main() { int a; std::cin >> a; std::cout << a << std::endl; return 0; }

the code is showing in one line in the forum for some reasons I don't know well
when I try to type input in the terminal ( I typed 5 three times and pressed enter because it didn't show in terminal )

it doesn't show in terminal and after stop debugging there was something like this command-----

$  /usr/bin/env c:\\Users\\User\\.vscode\\extensions\\ms-vscode.cpptools-1.4.1\\debugAdapters\\bin\\WindowsDebugLauncher.exe --
stdin=Microsoft-MIEngine-In-1kaltmip.ot3 --stdout=Microsoft-MIEngine-Out-hqhnwyp4.nus --stderr=Microsoft-MIEngine-Error-gbgj4wu
t.aya --pid=Microsoft-MIEngine-Pid-gywiyai2.5yw --dbgExe=D:\\ConsoleEmulators\\Cygwin\\Cygwin\\bin\\gdb.exe --interpreter=mi
User@User-PC ~
bash: 5: command not found
User@User-PC ~
bash: 5: command not found
User@User-PC ~