英文:
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:
"./a < inputfile.dat"
You can also try "ctrl-shift-d" and then select run and debug which should give you access to stdin in the terminal
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论