Search code examples
c++visual-studio-codevscode-code-runner

How can I run code in the terminal rather than the output panel using the Code Runner VS Code extension?


I want to execute code in terminal- not in the debugger.

After downloading all the c/c++ extension in vs-code. code

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

    cout<<"helloworld";
    cin>>UserInputOccur;
    cout<<UserInputOccur;
    return 0;
}

All the compilation and debugging done in debug console only till ( First user input i.e When first cin>>UserInputOccur; and then the code in terminated with helloworld1020=thread-exited,id="3",group-id="i1"


Solution

  • If you are using Linux you can write your code in a file, such as main.cpp.

    Then you can open terminal -> go to the directory of the file -> run command g++ main.cpp -o main.

    Now you can run your code on terminal with command ./main