1

I want to debug a code that has std::cin on it.

If I put on launch.json '"externalConsole": false', I can't write anything (because there's no console to work on it).

However, If I put "externalConsole": true, my args of the shell are just ignored.

I'm using just IntelliSense.

launch.json:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "g++.exe - Criar e depurar o arquivo ativo",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${fileDirname}",
            "environment": [],
            "externalConsole": true,
            "MIMode": "gdb",
            "miDebuggerPath": "C:\\MinGW\\bin\\gdb.exe",
            "setupCommands": [
                {
                    "description": "Habilitar a reformatação automática para gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "C/C++: g++.exe arquivo de build ativo"
        }
    ]
}

settings.json:

{
    "terminal.integrated.shell.windows": "C:\\Windows\\System32\\cmd.exe",
    "terminal.external.windowsExec": "C:\\Windows\\System32\\cmd.exe",
    "terminal.integrated.shellArgs.windows": [
        "/k",
        "chcp 65001"
    ],
    "workbench.colorTheme": "Visual Studio Dark - C++",
}

I need to use '"terminal.integrated.shellArgs.windows": ["/k", "chcp 65001"]' to use my encoding system.

Is there a way to work around this problem?

  • In such cases I create text file with the input and redirect standard input from it. It makes debugging more pleasant (no jumping between IDE and application). But I recommend try TDD/DDD. – Marek R Feb 13 '21 at 19:22
  • I've trying to put args just like: https://stackoverflow.com/questions/46259717/visual-studio-code-use-input-text-file-on-debug or with "<", "${fileDirname`}\\input.txt" and it's not working as either. Just works if I use the terminal (new terminal) – Gabriel Bernardes de Carvalho Feb 13 '21 at 19:27

0 Answers0