我已经安装了一段时间,以便在VS代码中运行C++程序。它基本上是一个tasks.json,看起来像这样
"tasks": [
{
"label": "Compile and run",
"type": "shell",
"command": "",
"args": [
"g++",
"${fileBasename}",
"-o",
"test",
"&&",
...
}我还保留了一个settings.json来定义要使用的终端,它是命令提示符,由于某些原因,在VS代码的最新更新中,我的设置变得混乱,它不再工作。
我想知道正确的语法来将cmd定义为运行任务的终端,因为像&& < >这样的东西在powershell中不起作用
发布于 2021-05-30 20:46:23
在Luuk的评论之后,我做了更多的挖掘,发现下面的代码可以解决我的vs代码任务问题。我只需要将&&改为;,对于输入输出重定向,我使用了这个answer。现在我的tasks.json看起来像这样
"tasks": [
{
"label": "Compile and run",
"type": "shell",
"command": "",
"args": [
"g++",
"${fileBasename}",
"-o",
"test",
";",
"cmd",
"/c",
"'test.exe < input.txt > output.txt'",
";",
"del",
"*exe",
";",
"del",
"${fileBasename}"
}
]https://stackoverflow.com/questions/67759393
复制相似问题