简体   繁体   English

Visual Studio Code集成终端不显示文本

[英]Visual Studio Code Integrated Terminal not Displaying Text

I'm brand new to MacOS and I am attempting to set up a programming environment, my IDE of choice being Visual Studio Code. 我是MacOS的新手,正在尝试建立一个编程环境,我选择的IDE是Visual Studio Code。 When the program runs it, by default, prints in output. 程序运行时,默认情况下在输出中打印。 However, output crashes when asked to gather input. 但是,当要求收集输入时,输出崩溃。 The online solution the I found for that was to output the code through the terminal, yet now nothing is displayed in the terminal. 我为此找到的在线解决方案是通过终端输出代码,但是现在终端中什么也没有显示。

I'm posting this here instead of a bug report as I'm unsure whether the fault is mine or the program's. 我将其发布在这里,而不是错误报告,因为我不确定是我的错误还是程序的错误。

Here is the simple code I am attempting to run: 这是我尝试运行的简单代码:

#include <iostream>

int main()
{
    int i;
    std::cout << "Enter a number: ";
    std::cin >> i;
    std::cout << "\n" << i;
    return 0; 
}

When run through output, it will display the first part, then crash when input is requested. 通过输出运行时,它将显示第一部分,然后在请求输入时崩溃。 When run through the terminal, the terminal only displays: "cd "(directory location)" && g++ main.cpp -o main && "(directory location)"main" and nothing else. 通过终端运行时,终端仅显示:“ cd”(目录位置)“ && g ++ main.cpp -o main &&”(目录位置)“ main”,而没有其他内容。

Below are my tasks.json and launch.json: 以下是我的task.json和launch.json:

tasks.json: task.json:

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "taskName": "c++ test program",
            "type": "shell",
            "command": "g++",
            "args": [
                "-g", "main.cpp"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}

launch.json: launch.json:

{
        "version": "0.2.0",
        "configurations": [
            {
                "name": "(lldb) Launch",
                "type": "cppdbg",
                "request": "launch",
                "program": "${workspaceRoot}/a.out",
                "args": [],
                "stopAtEntry": false,
                "cwd": "${workspaceRoot}",
                "environment": [],
                "externalConsole": true,
                "MIMode": "lldb"
            }
        ]
    }

The only setting that has been changed would be "code-runner.runInTerminal" which has been set to true. 唯一已更改的设置是已设置为true的“ code-runner.runInTerminal”。

This is true when using Code Runner so the solution is: 使用Code Runner时确实如此,因此解决方案是:
use Code Runner and then press Ctrl+, to edit settings then search for 使用Code Runner ,然后按Ctrl+,以编辑设置,然后搜索
code-runner.runInTerminal and set code-runner.runInTerminal to true , like so: code-runner.runInTerminal和一套code-runner.runInTerminaltrue ,就像这样:

{
    "code-runner.runInTerminal": true
}

this works fine for me. 这对我来说很好。
I hope this helps. 我希望这有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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