Why am I getting this incomplete output c++ in vscode?

Viewed 26

I am trying to compile and debug a simple code in vscode using Microsoft C++ extension and GCC compiler. I also have coderunner added as extension to the VScode so my output and input are displayed in the terminal. But when I am trying to run a simple code sample that uses con and cout objects respectively, I am getting an incomplete output. When I try to run the code on an online C++ compiler I am getting the full output, please help me figure out whats wrong with my compiler or setting in VSCode.

My code-

#include <iostream>
using namespace std;
int main(){

    int x;
    cin >> x;
    cout << "The number is " << x << "26";
     
     return 0;

}

INPUT:445

VSccode C++ OUTPUT:The number is445

Online C++ compiler output:The number is 44526

Also adding my tasks.json file for reference:

{
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: g++.exe build active file",
            "command": "C:\\Program Files (x86)\\mingw64\\bin\\gcc.exe",
            "args": [
                "-fdiagnostics-color=always",
                "-g",
                "${fileDirname}\\*.cpp",
                "-o",
                "${fileDirname}\\${fileBasenameNoExtension}.exe"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "Task generated by Debugger."
        }
    ],
    "version": "2.0.0"
}
0 Answers
Related