你的代码截一下
点那个中断,然后看代码停在哪一行
多半是野指针、数组越界,或者scanf没有加上取地址之类的问题
在 VS2013 中使用 scanf 输出函数时,编译会报错,提示我们使用scanf_s等相应的函数,虽然这种方法更有利于程序的安全,但很多时候很不方便,不利于代码的移植。
我们可以采取更好的方法:
1)添加预处理#pragma warning(disable:4996)
忽视该警告
2)添加预处理#define _CRT_SECURE_NO_WARNINGS
一般情况使用 VS2013 编译运行C语言代码时,可执行窗口会闪退从而看不见结果,如果不想让其消失,需程序中添加:system("pause");
system()就是调用(DOS)系统命令(和shell命令);
pause ,即DOS命令集合中的暂停命令;
注意:使用该语句需调用头文件#include<windows.h>
//Eg1:
#include<windows.h>
#include<stdio.h>
#pragma warning(disable:4996)
int main()
{
int a = 0;
printf("请输入执行操作:1、hello world 2、exit\n");
scanf("%d", &a);
if (a == 1)
printf("hello world!\n");
else
exit;
system("pause");
return 0;
}