在 VS Code 外部终端中输入后结束的 C 程序

问题描述

我在执行程序映射中进行了此更改以在外部终端中运行程序: “code-runner.executorMap”:{ "cpp": "g++ $fullFileName -o $fileNameWithoutExt.exe && start $fileNameWithoutExt.exe" }

程序确实开始在外部终端中运行,但在接受输入后结束。 这是简单的 C 代码

"react-redux"

enter image description here

程序在接受输入后结束。请帮我解决VS Code的这个问题。

解决方法

您编写了 urns,但窗口将关闭,因为它将退出。您需要在程序结束后保持窗口打开:

{ "cpp": "g++ $fullFileName -o $fileNameWithoutExt.exe && start /wait $fileNameWithoutExt.exe" }

命令启动的 /wait 选项将使用 /k 选项运行命令提示符,以确保这一点。