vscode-cpptools icon indicating copy to clipboard operation
vscode-cpptools copied to clipboard

running C/C++ outputs in debug console instead of terminal

Open Heckrexter opened this issue 3 years ago • 2 comments

Type: Bug

  1. write the code to execute with print statement
  2. Select the "Run C/C++ file" option
  3. you will see that if there any print statements all of it will happen in the debug console while in the terminal all you see is "executing task", "Starting build" and "Build finished successfully" instead of the output I expect which is "Test out"

Extension version: 1.12.4 VS Code version: Code 1.71.2 (Universal) (74b1f979648cc44d385a2286793c226e611f59e7, 2022-09-14T21:05:37.721Z) OS version: Darwin x64 21.6.0 Modes: Sandboxed: No

System Info
Item Value
CPUs Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz (12 x 2600)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off
Load (avg) 2, 2, 2
Memory (System) 16.00GB (1.41GB free)
Process Argv --crash-reporter-id dfa5ac12-218d-496d-b79f-7a9d361543d3
Screen Reader no
VM 0%
A/B Experiments
vsliv368:30146709
vsreu685:30147344
python383cf:30185419
vspor879:30202332
vspor708:30202333
vspor363:30204092
vslsvsres303:30308271
pythonvspyl392:30443607
vserr242:30382549
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vshan820:30294714
vstes263cf:30335440
pythondataviewer:30285071
vscod805cf:30301675
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
cmake_vspar411cf:30557515
vsaa593cf:30376535
pythonvs932:30410667
cppdebug:30492333
vsclangdf:30486550
c4g48928:30535728
hb751961:30553087
dsvsc012cf:30540253
azure-dev_surveyone:30548225
2144e591:30553903
vscccc:30566498
fc301958:30567733

Heckrexter avatar Sep 18 '22 17:09 Heckrexter

Do you have externalConsole set to true or false.

The Debug Console is not the output window, it is where diagnostics logging during debugging or using it as an evaluation window.

WardenGnaw avatar Sep 19 '22 23:09 WardenGnaw

Do you have externalConsole set to true or false.

The Debug Console is not the output window, it is where diagnostics logging during debugging or using it as an evaluation window.

I do not know where I can see external console and I am aware debug console is not the output window but for some reason that's the only place where I can see any print statements I put in my codes

Heckrexter avatar Sep 20 '22 11:09 Heckrexter

brother if this issue is resolved for you ..can you also enlighten me>?

Naaah-man avatar Jun 25 '23 10:06 Naaah-man

What is the solution?

Aarushssid avatar Jul 26 '23 03:07 Aarushssid

No solution found so far I just use an extension to run it called "Code Runner"

Heckrexter avatar Jul 26 '23 05:07 Heckrexter

Ah, but how are you debugging the code, I dont recall you could debug using code runner?

Aarushssid avatar Jul 27 '23 03:07 Aarushssid

I haven't really had to use the debugger, just use some print statements

Heckrexter avatar Jul 27 '23 05:07 Heckrexter

Alr thanks

Aarushssid avatar Jul 27 '23 22:07 Aarushssid

https://www.freecodecamp.org/news/how-to-write-and-run-c-cpp-code-on-visual-studio-code/ I had the same problem, my code kept running in the debugging console. Just follow the steps taken on this website, starting from the images on vscode (assuming you already have vscode installed) and you should be good to run the code right into the integrated terminal using the "run code" option. Hopefully this works for you guys.

jSreih avatar Aug 16 '23 15:08 jSreih

https://www.freecodecamp.org/news/how-to-write-and-run-c-cpp-code-on-visual-studio-code/ I had the same problem, my code kept running in the debugging console. Just follow the steps taken on this website, starting from the images on vscode (assuming you already have vscode installed) and you should be good to run the code right into the integrated terminal using the "run code" option. Hopefully this works for you guys.

That does not fix the problem, it simply bypasses it by using an extension that has been brought up earlier in the conversation.

Heckrexter avatar Sep 04 '23 14:09 Heckrexter

Just add these to the launch.json config:

"stopAtEntry": true,
"logging": {
                "engineLogging": false, // Show or hide detailed logging from the debug engine
                "programOutput": true, // Show or hide the output of the program being debugged
                "exceptions": true, // Show or hide exception information
                "moduleLoad": false, // Show or hide module loading information
                "trace": false, // Enables tracing of the Debug Adapter Protocol
                "traceResponse": false, // Show responses from the Debug Adapter Protocol
                "warnings": false, // Show or hide warnings from the debug engine
            },

The stop at entry is necessary or a debug help message will pop up at the first breakpoint.

F-Stuckmann avatar Feb 29 '24 09:02 F-Stuckmann