c - 在 VS Code 外部终端中输入后结束的 C 程序
问题描述
我在执行器映射中进行了此更改以在外部终端中运行程序:“code-runner.executorMap”:{“cpp”:“g++ $fullFileName -o $fileNameWithoutExt.exe && start $fileNameWithoutExt.exe”}
该程序确实开始在外部终端中运行,但在输入后结束。这是简单的C代码:
#include<stdio.h>
int main()
{
int x,y,l,a,b;
printf("Enter the bottom left co-ordinates of the square: ");
scanf(" %d %d", &x, &y);
printf("Enter the length of the square: ");
scanf(" %d", &l);
printf("Enter the co-ordinates to be checked: ");
scanf(" %d %d", &a, &b);
if((a>=x && a<=(x+l)) && (b>=y && b<=(y+l))) //boundary limits for four sides of the square
{
printf("\n%d,%d lies inside the square.", a,b);
}
else
{
printf("\n%d,%d don't lie inside the square.", a,b);
}
return 0;
}
然后程序在接受输入后结束。请帮我解决VS Code的这个问题。
解决方案
您对骨灰盒进行编程,但窗口将关闭,因为它会退出。程序结束后,您需要保持窗口打开:
{ "cpp": "g++ $fullFileName -o $fileNameWithoutExt.exe && start /wait $fileNameWithoutExt.exe" }
命令 start 的 /wait 选项将使用 /k 选项运行命令提示符,以确保这一点。
推荐阅读
- java - 根据属性类型获取 XmlElement 或 XmlValue
- javascript - HtmlUnit获取编码错误的字符串
- c++ - 以自定义类为键的 Unordered_map
- r - ggplot2() 按因子绘制一个变量与自身的关系?
- javascript - 为什么这个 Javascript 可以在浏览器控制台中工作,但不能在 Selenium 的 JavascriptExecutor 中工作?
- python-3.x - 这是将 Keras 与 tensorflow 数据集一起使用的错误吗?
- javascript - Flow 是特定 JavaScript 版本的衍生产品吗?
- java - 如何对稍后才定义的一般对象进行算术编程?
- python - 计算word2vec模型的perplexity
- ios - iOS SDK如何调用Lambda函数?