Reputation: 43
I am trying to compile and run C++ programs on VS code. I have my compiler set up, and I am trying to use the terminal for taking the user input. I tried to change the settings config for code runner by updating the
"code-runner.runInTerminal": true
After this, the terminal refuses to run the code. I understand the error that I am getting, but I have no clue on how I can fix it. Here is the program I am trying to run:
#include <bits/stdc++.h>
using namespace std;
int main()
{
int x;
cin >> x;
cout << "Output:" << x;
}
The output I get after I try to run it is:
cd "d:\Github\problem-solving\HackerRank\Cpp\" && g++ pointers.cpp -o pointers && "d:\Github\problem-solving\HackerRank\Cpp\"pointers
bash: cd: d:\Github\problem-solving\HackerRank\Cpp" && g++ pointers.cpp -o pointers && d:Githubproblem-solvingHackerRankCpp"pointers: No such file or directory
Upvotes: 0
Views: 3011
Reputation: 727
Looks like you have not set up your terminal root. Essentially, the code runner will try to look for a terminal root in contexts like these, and thus if it does not get one, it misreads the input file's name when you execute it. Essentially, set the value for "code-runner".terminalRoot to "/" (without the quotes). Here is a screenshot for reference.
This should get your code running in no time!
Upvotes: 2