作业帮 > 综合 > 作业

error C4996:'fopen':This function or variable may be unsafe.

来源:学生作业帮 编辑:灵鹊做题网作业帮 分类:综合作业 时间:2024/03/29 09:48:01
error C4996:'fopen':This function or variable may be unsafe.Consider using fopen_s instead.To disable deprecation,use _CRT_SECURE_NO_WARNINGS.See online help for details.
//假设b=3m,h=100m,ms=2.89 a为板状体倾角 ,is为有效磁化倾角
//#define _CRT_SECURE_NO_WARNINGS
#include
#include
void main()
{
\x09FILE *fp1,*fp2;
\x09fp1 = fopen("H:\\c程序\\试试\\za.txt","w+");
\x09fp2 = fopen("H:\\\c程序\\试试\\ha.txt","w+");
\x09double u;
\x09u = 12.56* pow(10,-7);
\x09float za[50],ha[50],a,is,r;
\x09int b,h,x;
\x09b = 3;
\x09h = 100;
\x09float ms = 2.89;
\x09printf("输入倾角a和磁化角is:\n");
\x09scanf("%d,%d",&a,&is);
\x09a = a*3.14 / 180;
\x09is = is*3.14 / 180;
\x09r = a - is;
\x09for (x = -100; x < 100; x += 5)
\x09{
\x09\x09za[x] = (u / 2 * 3.14) * 2 * b*ms*sin(a)*(h*cos(r) - x*sin(r)) / (x*x + h*h);
\x09\x09ha[x] = (u / 2 * 3.14) * (-2) * b*ms*sin(a)*(h*sin(r) + x*cos(r)) / (x*x + h*h);
\x09\x09fprintf(fp1,"%d %f\n",x,za[x]);
\x09\x09fprintf(fp2,"%d %f\n",x,ha[x]);
\x09}
\x09fclose(fp1);
\x09fclose(fp2);
}
error C4996:'fopen':This function or variable may be unsafe.
你用的是VS2012吧= =.2012开始就对很多函数进行重写,因为微软觉得以前的函数不安全.fopen被fopen_s代替了.