mardi 2 juin 2020

Can't receive cin in c++ program in Windows vscode

I have been trying to figure out how to receive input in Windows vscode c++ program for example using cin. I have already tried running with MingW and cl and both have the same result.

Terminal output is being sent to vscode debugconsole and I can't interact with the program.

Here is my tasks.json

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "cl.exe build active file",
            "type": "shell",
            "command": "c:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe",
            "args": [
                "/Zi",
                "/EHsc",
                "/Fe:",
                "${fileDirname}\\${fileBasenameNoExtension}.exe",
                "${file}"
            ],
            "group": "build",
            "presentation": {
                // Reveal the output only if unrecognized errors occur.
                "reveal": "silent"
            },
            // Use the standard MS compiler pattern to detect errors, warnings and infos
            "problemMatcher": "$msCompile"
        }
    ]
}

And here is my launch.json file:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(Windows) Launch",
            "type": "cppvsdbg",
            "request": "launch",
            "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "preLaunchTask": "cl.exe build active file"
        }
    ]
}

I've seen other suggestions like using "code-runner.runInTerminal": true and "terminal": "integrated" but this has not worked for me. I have already seen this other post: Visual Studio Code: Take Input From User

But so far no joy.

Aucun commentaire:

Enregistrer un commentaire