Yang Seung Chan
Yang Seung Chan

Reputation: 21

How c++ program read user input in VSCode while debugging

I'm trying to do debugging c/c++ program in vscode debug tab. Well, after setting some properties which is spread through google, it works well. However, when I try to do debug with program containing "scanf" or "cin" which requires user input, it never receives any input from my keyboard. How can I do so?

And what I found from google is that setting "externalConsole" value as true like this picture.

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "g++ - 활성 파일 빌드 및 디버그",
      "type": "cppdbg",
      "request": "launch",
      "program": "${workspaceFolder}/Sort/test",
      "args": [],
      "stopAtEntry": false,
      "cwd": "${workspaceFolder}",
      "environment": [],
      "externalConsole": true,
      "MIMode": "lldb",
      "preLaunchTask": "C/C++: g++ build active file"
    }
  ]
}

However, if I change the value of externalConsole as true and try to debug program containing cin, there is no progress after the below picture.

the moment tryting to debug the given program

Even though I try to input the data in the external console(for example "asd"), it says "zsh:command not found asd". How can I fix it for program to receive my input. HELP ME PLZ

Upvotes: 0

Views: 1322

Answers (1)

Barkhayot Juraev
Barkhayot Juraev

Reputation: 17

  1. install CodeRunner extension on your VSCode
  2. and then follow steps : Code -> Preferences -> Settings
  3. then on setting type CodeRunner Settings
  4. find the Run In Terminal
  5. Enable that function

Follow these steps and you will be able to run your code on VSCode terminal and it would be possible to enter Input

enable this

Upvotes: 2

Related Questions