问题描述
如图,直接点运行出现如下提示:
但是分开执行还是正常的:
原因
cmd执行多条语句要使用" && “作为连接符,对应的powerShell要用” ; "。
解决
在用户设置中修改code-runner.executorMap中对应的值
- vscode中ctrl+shift+p搜索settings.json打开用户设置(open user settings)进入json文件
- ctrl+f搜索code-runner.executorMap定位到相应位置如下
"code-runner.executorMap": {
//……
// "cpp": "cd $dir ; g++ $fileName -o $fileNameWithoutExt ; .\\$fileNameWithoutExt",//powershell中间分隔符用";"
"cpp": "cd $dir && g++ $fileName -o $fileNameWithoutExt && .\\$fileNameWithoutExt",
//……
}
- 替换对应控制台的连接符