skip to Main Content

I want to run a C++ program in VS Code. All I get from Google is that click on run and debug (the play button) on top right in VS Code and my program will be up and running. I don’t want to do from that. I want to do it from terminal.

Example, to run:

  1. A Python file I do: python3 fileName.py
  2. A Flutter program: flutter run
  3. A Java file: javac fileName.java
  4. A Go file: go run fileName.go

Is there any command similar like this in C++?

Apologies, I know my question is a little naïve.

2

Answers


  1. Chosen as BEST ANSWER

    I need to be in my project directory and then i need to run

    g++ 01inputFromUser.cpp -o 01inputFromUser && "/home/aman/Desktop/arjun/cpp/"01inputFromUser
    

    so this was what I was looking for

    g++ fileName.cpp -o fileName && "/path/to/project/"fileName
    

  2. i guess the short answer would be :

    $ g++ -o < name-you-want-to-give> source.cpp

    In place of replace it by any name like myprogram, etc.
    ./myprogram

    This mean you had to install gcc compiler beforehand.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search