I am trying to run a simple program "primeRange.cpp" using Code Runner extension available for VSCode.
I have selected my default terminal as git bash in VSCode, but when I hit Run on top right corner, it sends the command to bash to run the program using g++ compiler, but I am getting error as no such file or directory, when there exists a directory with the given name.
How can I fix this?
How can I customize which command to hit on bash when I press run on code runner?
I want to set the command as :
cd "c:\\Users\\Tushar\\Desktop\\contests\\Practice" && g++ primeRange.cpp -o primeRange && "c:\\Users\\Tushar\\Desktop\\contests\\Practice\\primeRange"
OR
cd "c:\Users\Tushar\Desktop\contests\Practice" && g++ primeRange.cpp -o primeRange && "c:\Users\Tushar\Desktop\contests\Practice\primeRange"
If I am executing any one of the above command manually on bash then it's working.
So I basically want to know that how to include the executable filename inside the path as:
"c:\Users\Tushar\Desktop\contests\Practice\primeRange"
instead of after the quotes as :
"c:\Users\Tushar\Desktop\contests\Practice\"primeRange
I have updated the path in settings.json to:
"code-runner.executorMap": {
"cpp": "cd $dir && g++ -std=c++11 $fileName -o $fileNameWithoutExt && \"./$fileNameWithoutExt.exe\""
},
But now I am getting prompt instead of asking for stdin as given below:
RESOLVED
Fix 1:
Updating code-runner.executorMap property in settings.json as
"code-runner.executorMap": {
"cpp": "cd $dirWithoutTrailingSlash && g++ -std=c++11 $fileName -o $fileNameWithoutExt && ./$fileNameWithoutExt"
}
Fix 2:
Adding another property code-runner.terminalRoot in settings.json as:
"code-runner.terminalRoot": "/"