简体   繁体   中英

How to accept user input in Visual Studio Code integrated Terminal?

I've searched for this answer but it was futile, a lot of threads are open with no answer whatsoever or the answer is just not the one that was asked.

How do I use the integrated terminal that comes on the bottom of VS:Code?

终端 VS 代码概述

That allows the user to input and also see the text that is printed on the terminal when one normally executes a program.

I'm learning C and I can't make it work there.

As you can see, if I run my code through the debugger, it doesn't work, AKA does not allow user input.

不接受用户输入

Keep in mind that this is what happens if I use launch.json option called "externalConsole": , and set it to true. 外部控制台

But also this has it's drawbacks (for example as soon as the code finishes running the console exits and ceases existence therefore one can't read the output of the program)

How can this be solved? I've seen it working fine but on Linux environment computers. Thanks.

The launch.json file has a "console" setting, which you must set to "integratedTerminal" (the default is "internalConsole" , which only displays output from your program).

  • The launch.json file is the configuration for your project's debugging sessions. You can open it via the command palette with Debug: Open launch.json or by clicking the cogwheel icon in the toolbar at the top of the Run view: 在此处输入图片说明

Starting a debugging session automatically switches to the DEBUG CONSOLE tab in the panel (lower window pane).
Switch to TERMINAL to interact with your console application.

See the docs for more information.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM