Cover photo by Clément H on Unsplash
Trying to figure out how to add user input while debugging C++ on macOS in VScode? You've come to the right place. I spent a load of time figuring it out so that you don't have to.
Aight, I'll make this post a tl;dr and give references for further reading at the bottom.
Step #1
Update your tasks.json file (In case you don't know what that is, I suggest you head over here and then get back) with the following piece of code.
{"label": "Open Terminal",
"type": "shell",
"command": "osascript -e 'tell application \"Terminal\"\ndo script \"echo hello\"\nend tell'",
"problemMatcher": []
}
Now just run this task before running the c++ file, and in the launch.json, set
externalConsole: true
Your tasks.json should look something like this now.
Step #2
Now hit
cmd + shift + P
and type in ">run tasks" without the quotes of course.
And you should see something like this.
Click on
open terminal
Top comments (0)