Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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. 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.

Below are my tasks.json and launch.json:

tasks.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:

{
        "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.

like image 372
HarpoN Avatar asked Nov 07 '22 16:11

HarpoN


1 Answers

This is true when using Code Runner so the solution is:
use Code Runner and then press Ctrl+, to edit settings then search for
code-runner.runInTerminal and set code-runner.runInTerminal to true, like so:

{
    "code-runner.runInTerminal": true
}

this works fine for me.
I hope this helps.

like image 91
wasmup Avatar answered Nov 14 '22 22:11

wasmup