I've always used Sublime Text 3 for Python Coding, in which Build Systems
were the only way of running a file.
Now I'm starting C++ programming, and I'm using VSCode
. The problem I have is that, in that dock where:
PROBLEMS
, OUTPUT
, DEBUG CONSOLE
, TERMINAL
The only thing I've had trouble with, is OUTPUT
window, because nothing ever appears, so if I wanna run either Python or C++ code, it won't show anything to let me know what output would the program give. And if I just try to run it (pressing f5) it, it will open terminal and run it from it.
I saw something called Tasks
but I don't know how they work, and they seem to be like Build Systems
from Sublime Text 3.
I wanna use OUTPUT
window, how can I get it working?
to run code in the output section of visual studio code you can use the extension Code Runner
just install, then press CTRL + ALT + N
to run the file (supports c++ & python)
I wanna use OUTPUT window, how can I get it working?
As it stands now, you can not use the Output Window as a way to log code, that is reserved for native logs like Window, Main, Shared or Extensions to log their output using channels. There is a good candidate called the Debug Console.
You can log to the Debug Console using a launch.json
configurable:
First, create a launch.json for your program.
Then add the following properties, in addition to whatever you need to get your program going:
internalConsoleOptions
Controls when the internal debug console should open
redirectOutput
Both of these used in tandem will open the 'Debug Console' instead of terminal and just provide the necessary output; though it still sends to terminal should you still want it:
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"internalConsoleOptions": "openOnSessionStart",
"redirectOutput": true
}
]
For c++ they have an extensive tutorial on how to debug and run: https://code.visualstudio.com/docs/languages/cpp (in addition to setting up launch.json
and tasks.json
files respectively https://code.visualstudio.com/docs/cpp/config-mingw#_build-helloworldcpp )
Installation Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
ext install formulahendry.code-runner
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.