Reputation: 171
I want to compile C++ in VSCode. I followed the walkthrough here
When I run the example program in VSCode terminal, nothing is output into the terminal. I tried in powershell and in cmd using the dropdown in VSCode terminal window.
When I run the .exe from a standalone cmd
terminal, it works fine. Could the problem be something about not knowing how to write the output? I'm guessing the program runs but just doesn't know where to output.
Upvotes: 1
Views: 6385
Reputation: 1
I encountered the same problem and by pure chance following worked in my case: When I opened VSC from a GIT shell via 'code .', I didn't get any output from a shell within VSC. But when I opened VSC from windows command prompt via 'code .' and executed the same file again and it worked.
Upvotes: 0
Reputation: 11
Command Prompt method :
first changer the directory to where file is located.
g++ -o program Menu-driven-program-DAA.cpp&program.exe
Running Cpp program through powershell terminal in vscode:
g++ -o program Menu-driven-program-DAA.cpp
.\program.exe
I've mentioned both the commands in vscode powershell terminal seperately because it throws an error
Note:- try gcc instead of g++ if it doesn't works for me only g++ did.
Upvotes: 1
Reputation: 171
I opened VS code before adding mingw to my PATH. I simply had to restart VS code. I really figured each time I opened a new terminal in VS Code, it would.. open a new terminal. Perhaps they do some kind of virtual terminal and it's really all one terminal from launch? Who knows. Either way, restart VS code.
Upvotes: 2