[英]C program ending after taking input in VS Code External Terminal
我在执行程序 map 中进行了此更改以在外部终端中运行程序:“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的这个问题。
您对骨灰盒进行编程,但 window 将被关闭,因为它将退出。 程序结束后,您需要保持 window 打开:
{ "cpp": "g++ $fullFileName -o $fileNameWithoutExt.exe && start /wait $fileNameWithoutExt.exe" }
命令 start 的 /wait 选项将使用 /k 选项运行命令提示符,以确保这一点。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.