vs2013程序运行完后闪退的问题
c吧
全部回复
仅看楼主
level 4
yudongzhang88 楼主
初学c,程序运行完后会闪退。
之前没有scanf_s函数用getchar();可以解决闪退问题,今天刚用这个函数又出现了闪退。
其他地方搜到的解决方案:
1.Ctrl+F5运行
2.system(“pause”);
3.getchar();
全!都!没!用!
这是我的程序
希望各位大神帮帮我
2014年07月14日 12点07分 1
level 12
system
2014年07月14日 17点07分 2
level 5
不用getchar,换成用scanf_s
2014年12月11日 03点12分 5
level 7
return前面加system("pause");,我一直是这样解决的
2014年12月11日 11点12分 7
恭喜你,这个命令在POSIX里是没有的
2015年06月18日 08点06分
level 6
为什么不是void main
2014年12月11日 16点12分 8

2015年05月06日 09点05分
不是正确的写法 有的编译器不承认 int main(void) 这样写最好
2015年07月17日 13点07分
回复
eternal����
:dev编译器就不认
2015年07月27日 14点07分
level 7
c中用system("pause")的时候得引用头文件stdlib.h
或者用getch()。
我说的是c,不知道c++可不可以。。
2014年12月13日 01点12分 10
c plus 不需要,用过dev吗
2015年07月27日 14点07分
level 1
vs2013,c++用这个system("pause")可以防止闪退的。
2015年01月31日 08点01分 11
我知道这样挖坟了,首先说声抱歉。我也出现了楼主的情况,然后试了试层主的建议,也解决了。能问下问为什么吗?
2015年09月13日 01点09分
我也想问问 为什么啊 我同学的电脑都不用加[啊]
2015年10月07日 14点10分
@开阝田心田心💍 兼容性问题
2016年04月24日 06点04分
level 4
为什么我这么做都能防止闪退?
2015年01月31日 09点01分 12
level 5
#include <stdio.h>
#include <math.h>
#include <conio.h>
int main(void)
{
int a,b,c;
scanf("%d%d",&a,&b);
c=max(a,b);
printf("%3d%3d,max=%3d\n",a,b,c);
}
int max(int x,int y)
{
x>y?x:y;
}
2015年01月31日 11点01分 13
max函数要先申明再掉用,还有少了个Return,一般这种简短的函数,用宏#define 效率更高
2015年02月02日 07点02分
这个用不着math. conio这两个头文件 不要就可以
2015年02月03日 09点02分
level 1
你是不是运行的时源.cpp不是这个cpp,一般不会出现这种问题的!
2015年01月31日 13点01分 14
level 1
ctrl+f5
2015年02月02日 02点02分 15
level 10
路过
2015年02月02日 02点02分 16
level 1
可以再return前加个while(1);
死空循环
2015年02月02日 07点02分 17
你CPU不要钱吗?
2015年02月03日 05点02分
叼……
2016年07月04日 06点07分
level 8
再加句gerchar就好。
2015年02月02日 10点02分 18
我也楼主这情况,确认有用
2015年04月21日 13点04分
level 10
[汗]
2015年02月02日 15点02分 19
level 5
建工程的时候有一个选项,啥啥生命周期还是啥周期来着。把那个勾去掉就好了,Ctrl+F5编译运行。
2015年02月02日 15点02分 20
这个好用 多谢!
2016年09月12日 13点09分
[大拇指]
2017年03月05日 12点03分
level 9
你就当gcc编译的鬼吧[滑稽]
有钱就能任性,没钱只能认命
2015年02月02日 17点02分 21
level 1
主函数声明有问题?我记得应该是int tmain(int argc,TCHAR* args[])《-记不清了
2015年02月04日 10点02分 22
恭喜你,你使用了一个只有Windows用的入点。
2015年06月18日 08点06分
level 6
其他方法没用,直接while(1);不就可以了,小程序随便玩嘛
2015年02月04日 10点02分 23
1 2 3 尾页