請問為什麼我的這個程序在vs 2013運行的時候會有問題,但是我卻可以用vs 2010運行?
#include <stdio.h>#include <math.h>
main()
{
float data1, data2;
char op;
printf("Please enter the expression:\n");
scanf ("%f %c%f", &data1, &op, &data2);
switch (op)
{
case '+':printf("%f+%f=%f\n", data1, data2, data1 + data2);
break;
case '-':printf("%f-%f=%f\n", data1, data2, data1 - data2);
break;
case '*':printf("%f*%f=%f\n", data1, data2, data1 * data2);
break;
case '/':if (fabs(data2) <= 1e-7) //与实数0比较
printf("Division by zero!\n");
else
printf("%f/%f=%f\n", data1, data2, data1 / data2);
break;
default: printf("Unknow operator! \n");
}
}
我在vs 2013運行的時候有把"scanf"改成"scanf_s",可是運行的時候會這樣: