Had the same problem. Here’s what I did & it got me the results I wanted.
- Go to the Terminal of Visual studio code.
- Cd to the directory of the file that has the code you wrote and ran. Let's call the program "
xx.cpp
"
- Type
g++ xx.cpp -o a.out
(creates an executable)
- To run your program, type
./a.out