
c语言程序闪退
新手自学c语言如下:#include<stdio.h>#include<math.h>voidmain(){doublex,s;printf("inputnumber:\...
新手自学c语言如下:
#include<stdio.h>
#include<math.h>
void main()
{
double x, s;
printf("input number:\n");
scanf("%lf", &x);
s = sin(x);
printf("sin of %lf is %lf\n", x, s);
}
打开文件夹所对应程序时闪退,添加return 0后程序就无法编译,我用的是vc6.0 展开
#include<stdio.h>
#include<math.h>
void main()
{
double x, s;
printf("input number:\n");
scanf("%lf", &x);
s = sin(x);
printf("sin of %lf is %lf\n", x, s);
}
打开文件夹所对应程序时闪退,添加return 0后程序就无法编译,我用的是vc6.0 展开
3个回答
追问
用软件刚写好的时候是可以运行的,但是当把代码从文件夹中打开运行时就闪退
追答
运行编译并连接后的可运行程序(.exe)时确实是这样,改进的方法是,在main()函数的右花括号”}“之前加一句system("pause");,重新编译、连接后,再运行可执行程序时,会有提示"按任意健继续......",等待用户击任意键,此后才会退出程序。
#include <stdlib.h> // for system();
......
int main() {
.......
system("pause");
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询