Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS Code does not show output from a program

I've created a c++ project on ubuntu in visual studio code. It launches the program using gdb mode, but does not show anything in Output. When I launch program from console, the output is present. I tried inserting "console" property, but vscode tells me, that it is forbidden (from similar issue with node https://github.com/Microsoft/vscode/issues/30842).

How can I enable vscode to show the output from my program?

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/a.out",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": true,
            "MIMode": "gdb",            
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ]
        }
    ]
}
like image 761
Rob Yart Avatar asked Feb 07 '18 15:02

Rob Yart


People also ask

How do I display output in VS Code?

To open the Output window, on the menu bar, choose View > Output, or press Ctrl+Alt+O.

How do I display the output code in Visual Studio C++?

From a command prompt or a new VS Code Integrated Terminal, you can now run your program by typing ".\helloworld". If everything is set up correctly, you should see the output "Hello World". This has been a very simple example to help you get started with C++ development in VS Code.

Why isn't my VS Code working?

Try uninstalling and reinstalling VS Code. If code is still not found, consult the platform-specific setup topics for Windows and Linux. On macOS, you need to manually run the Shell Command: Install 'code' command in PATH command (available through the Command Palette Ctrl+Shift+P).

Why code Runner is not working?

Looks like you haven't saved the file. Try saving the file and then run with Code Runner. Tip: You can enable Save before Run settings so that it gets saved every time before running the file. code runner says it will run code that is not saved yet.


2 Answers

You config is correct. The program output should be in the DEBUG CONSOLE.

Menu | Debug Console or Ctrl+Shift+Y.

like image 94
273K Avatar answered Oct 08 '22 16:10

273K


The program was launched in external terminal and due to the configuration of my screen I didn't see it. Everything works fine.

like image 31
Rob Yart Avatar answered Oct 08 '22 18:10

Rob Yart