0

When I do a "Run Code" command in Visual Studio Code in Windows (it's the first option when I right-click in the editor), the std::cout output goes to the "Output" pane of VSCode. But when this happens, where is std::cin? You can't type in the "Output" pane, and the code hangs at any cin lines.

Is there some other place that's working as std::cin when I run this way? And if not, is there some way to configure the "Run Code" command so that cin and cout go to a terminal? I've already tried editing the console argument of settings.json, like the first solution to this github issue (or its latest equivalent, since the externalConsole option is deprecated), but it doesn't help, I think because output just isn't going to any console at all.

(also, the "Run Code" command does not enter a debugging session, just compiles and executes. Regular debugging works fine and cin and cout go to the terminal specified in settings.json)

AJ Biffl
  • 493
  • 3
  • 10
  • If you're [debugging](https://code.visualstudio.com/docs/editor/debugging), you should see output in debug console. – Louis Go Aug 04 '21 at 07:08
  • 1
    Sorry, the debug and run I mean (whatever F5 does by default). In any case, ```cin``` isn't broken during debugging and that's not what I'm asking about. – AJ Biffl Aug 04 '21 at 07:17

1 Answers1

0

what you say is provided with two extension of VSCode.

  • The "Run Code" command in right click menu is likely provided by extension Code Runner
  • The 'settings.json' and the issue talks about the Microsoft's official C/C++ support extension C/C++

For you case, you may need to set this setting for Code Runner if you want to use the stdin of process

"code-runner.runInTerminal": true,
Chen Liu
  • 81
  • 7