<small id='AUSTL'></small><noframes id='AUSTL'>

      1. <tfoot id='AUSTL'></tfoot>
          <bdo id='AUSTL'></bdo><ul id='AUSTL'></ul>
        <legend id='AUSTL'><style id='AUSTL'><dir id='AUSTL'><q id='AUSTL'></q></dir></style></legend>

      2. <i id='AUSTL'><tr id='AUSTL'><dt id='AUSTL'><q id='AUSTL'><span id='AUSTL'><b id='AUSTL'><form id='AUSTL'><ins id='AUSTL'></ins><ul id='AUSTL'></ul><sub id='AUSTL'></sub></form><legend id='AUSTL'></legend><bdo id='AUSTL'><pre id='AUSTL'><center id='AUSTL'></center></pre></bdo></b><th id='AUSTL'></th></span></q></dt></tr></i><div id='AUSTL'><tfoot id='AUSTL'></tfoot><dl id='AUSTL'><fieldset id='AUSTL'></fieldset></dl></div>
      3. Visual Studio Code:从用户获取输入

        时间:2023-08-03
              <i id='iADPL'><tr id='iADPL'><dt id='iADPL'><q id='iADPL'><span id='iADPL'><b id='iADPL'><form id='iADPL'><ins id='iADPL'></ins><ul id='iADPL'></ul><sub id='iADPL'></sub></form><legend id='iADPL'></legend><bdo id='iADPL'><pre id='iADPL'><center id='iADPL'></center></pre></bdo></b><th id='iADPL'></th></span></q></dt></tr></i><div id='iADPL'><tfoot id='iADPL'></tfoot><dl id='iADPL'><fieldset id='iADPL'></fieldset></dl></div>
              <legend id='iADPL'><style id='iADPL'><dir id='iADPL'><q id='iADPL'></q></dir></style></legend>

              <tfoot id='iADPL'></tfoot>

              <small id='iADPL'></small><noframes id='iADPL'>

              • <bdo id='iADPL'></bdo><ul id='iADPL'></ul>
                    <tbody id='iADPL'></tbody>

                • 本文介绍了Visual Studio Code:从用户获取输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  目前,我正在尝试用 Visual Studio 代码编写 C/C++ 程序.为此,我安装了两个扩展:C/C++ &C++ 智能感知

                  Currently, I'm trying to write C/C++ program in Visual Studio code. For this I've installed two extensions: C/C++ & C++ Intellisense

                  根据文档,调试工具不适用于 Windows.我已经能够通过以下任务构建和运行代码:

                  As per the documentation, the debugging facility is not available for windows. I've been able to build and run the code with the following tasks:

                  {
                      "version": "0.1.0",
                      "command": "cmd",
                      "isShellCommand": true,
                      "args": [
                          "/C"
                      ],
                      "tasks": [
                          {
                              "taskName": "Makefile",
                              "suppressTaskName": true,
                              // Make this the default build command.
                              "isBuildCommand": true,
                              // Show the output window only if unrecognized errors occur.
                              "showOutput": "always",
                              // No args
                              "args": [
                                  "C:/Programs/cygwin/bin/make.exe",
                                  "all"
                              ],
                              // Use the standard less compilation problem matcher.
                              "problemMatcher": {
                                  "owner": "cpp",
                                  "fileLocation": [
                                      "relative",
                                      "${workspaceRoot}"
                                  ],
                                  "pattern": {
                                      "regexp": "^(.*):(\d+):(\d+):\s+(warning|error):\s+(.*)$",
                                      "file": 1,
                                      "line": 2,
                                      "column": 3,
                                      "severity": 4,
                                      "message": 5
                                  }
                              }
                          },
                          {
                              "taskName": "Run",
                              "suppressTaskName": true,
                              "isTestCommand": true,
                              "args": [
                                  "helloworld"
                              ]
                          }
                      ]
                  }
                  

                  和一个简单的Makefile:

                  all: clean helloworld
                  
                  helloworld: helloworld.cpp
                      C:/Programs/cygwin/bin/g++ helloworld.cpp -o helloworld
                  
                  clean:
                      C:/Programs/cygwin/bin/rm -rf helloworld
                  

                  但是,当程序在运行时需要一些用户输入时,就会出现问题.假设对于这个非常熟悉的 helloworld 程序.

                  But, the problem arises, when the programs needs some user input while running. Suppose for this very familiar helloworld program.

                  # include <iostream>
                  
                  using namespace std;
                  
                  int main ()
                  {
                    int name;
                  
                    cin >> name;
                  
                    cout << "Hello, " << name << "!!!" << endl;
                  
                    return 0;
                  }
                  

                  你能帮我在运行时获取用户输入吗?有一种变通方法可以将输入作为命令行参数传递.但是,对于具有复杂流程的程序来说,这是不可能的.

                  Can you please help me to get the user input at run time. There is a work-around to pass the input as command line arguments. But, that is not possible for programs with complex flows.

                  推荐答案

                  转到 Code ->首选项 ->设置并添加自定义设置:

                  Go to Code -> Preferences -> Settings and add custom settings:

                  {
                     "code-runner.runInTerminal": true
                  }
                  

                  最后运行你的 C++ 代码,你将能够在控制台中输入值

                  Finally run your c++ code and you will be able to enter values in console

                  这篇关于Visual Studio Code:从用户获取输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何在 Visual Studio Code 中包含编译器标志? 下一篇:Visual Studio Code c++11 扩展警告

                  相关文章

                  最新文章

                  <legend id='NuiOB'><style id='NuiOB'><dir id='NuiOB'><q id='NuiOB'></q></dir></style></legend>

                    <tfoot id='NuiOB'></tfoot>
                      <bdo id='NuiOB'></bdo><ul id='NuiOB'></ul>

                    <small id='NuiOB'></small><noframes id='NuiOB'>

                    <i id='NuiOB'><tr id='NuiOB'><dt id='NuiOB'><q id='NuiOB'><span id='NuiOB'><b id='NuiOB'><form id='NuiOB'><ins id='NuiOB'></ins><ul id='NuiOB'></ul><sub id='NuiOB'></sub></form><legend id='NuiOB'></legend><bdo id='NuiOB'><pre id='NuiOB'><center id='NuiOB'></center></pre></bdo></b><th id='NuiOB'></th></span></q></dt></tr></i><div id='NuiOB'><tfoot id='NuiOB'></tfoot><dl id='NuiOB'><fieldset id='NuiOB'></fieldset></dl></div>