标准输入在Visual Studio Code中

huangapple go评论55阅读模式
英文:

Standard input in visual studio code

问题

So I made a usaco program in c++, and I was trying to debug it. however, I was trying to put in standard input (I commented out the freopen), but I can't figure out where to type it. I got frustrated and now Im confused. Any help would be great, thank you!

I was trying to find a way to type input. I enabled the settings in run code configurations, but it still won't work.

EDIT: I am using c++ to write my code.

英文:

So I made a usaco program in c++, and I was trying to debug it. however, I was trying to put in standard input (I commented out the freopen), but I can't figure out where to type it. I got frustrated and now Im confused. Any help would be great, thank you!

I was trying to find a way to type input. I enabled the settings in run code configurations, but it still won't work.

EDIT: I am using c++ to write my code.

答案1

得分: 0

尝试从终端运行您的代码。这将直接为您提供一个终端,您可以在其中键入标准输入。您可以在Visual Studio Code中从终端 - 新终端中打开一个新终端。从终端取决于您正在使用的编程语言。

如果您有一个名为“file”的输入文件,您可以在终端中使用重定向将该文件传递给您的程序。根据您的实际操作,有很多选项。如果您有一个名为a的可执行文件,您可以这样写:

"./a < inputfile.dat"

您还可以尝试“ctrl-shift-d”,然后选择运行和调试,这应该会为您提供终端中的标准输入。

英文:

Try running your code from the terminal instead. This will give you access, directly, to a terminal where you can type stdin. You can open a new one in Visual Studio Code from Terminal - New Terminal. From the terminal it depends what language you were programming in.

If you have an input "file", you can use redirection from the terminal to push that file into your program. There are a lot of options depending on what you're actually doing. If you have an executable named a you might write:

&quot;./a &lt; inputfile.dat&quot;

You can also try "ctrl-shift-d" and then select run and debug which should give you access to stdin in the terminal

huangapple
  • 本文由 发表于 2023年2月27日 09:42:03
  • 转载请务必保留本文链接:https://go.coder-hub.com/75576145.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定