问题描述
我已经设置了一段时间来在 VS Code 中运行 C++ 程序。它基本上是一个看起来像这样的 tasks.json
"tasks": [
{
"label": "Compile and run","type": "shell","command": "","args": [
"g++","${fileBasename}","-o","test","&&",...
}
我还保留了一个 settings.json 来定义要使用的终端,即命令提示符, 出于某种原因,在 VS Code 的最新更新中,我的设置变得一团糟,不再起作用。
我想知道将 cmd
定义为运行任务的终端的正确语法,因为 &&
<
>
之类的东西在 powershell 中不起作用
解决方法
在 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","${fileBasename}"
}
]