配置:vs2013;
按照书上的内容学些C语言,自己尝试编写计算器,因为原书上代码是:
scanf("%lf %c %1f", &input_value1,&operator_select ,&input_value2 );
vs2013使用提示error,推荐使用scanf_s。
在使用scanf_s遇到坑如下:
一、编码的例程代码如下:
double input_value1 = 0.0;
double input_value2 = 0.0;
double output_value = 0.0;
char operator_select = 0;
printf(“Please Enter the calculation\n”);
scanf_s("%lf %c %1f", &input_value1,&operator_select ,&input_value2 );
运行后xx.exe后跑死,报警提示如下:
二、添加断电监控,怀疑如下代码有问题:
scanf_s("%lf %c %1f", &input_value1,&operator_select ,&input_value2 );
拆分该语句,代码如下:
printf("Please Enter the value\n");
scanf_s("%lf", &input_value1);
printf("Ple