Microsoft Visual Studio C 运行库在 xiuzheng.exe 中检测到一个错误。不知道为什么?希望高手能解决一下。
#include<stdio.h>#include<stdlib.h>
#include<math.h>
#include<string.h>
struct
{
char date[27];
float B;
float L;
float H;
char conf[11];
}data;
struct
{
float x;
float y;
float z;
float b;
float l;
float h;
}result;
void main()
{
FILE *fp1,*fp2,*fp3;
char datn[100],resn[100],head[10000];
double N,e,pi=3.1415926;
long int a,length;
strcpy(datn,"e:\\cpp\\data\\");length=strlen(datn);
if((fp3=fopen("e:\\cpp\\data\\dataname.txt","r"))==NULL)
{
printf("can not open the name file\n");
exit(0);
}
while(1)
{
fgets(&datn[length],100,fp3);
datn[70]='\0';
if((fp1=fopen(datn,"rb"))==NULL)
{
printf("can not open file:%s\n",datn);
exit(0);
}
if(feof(fp1))
break;
a=1737612;e=1/973.463;
do
{
fgets(head,10000,fp1);
}while(strcmp(head,"END\n"));
fgets(head,10000,fp1);
while(1)
{
fgets(data.date,25,fp1);
fscanf(fp1,"%f%f%f",&data.B,&data.L,&data.H);
fgets(data.conf,11,fp1);
if((data.L>=10&&data.L<20)&&(data.B>=50&&data.B<60))
{
strcpy(resn,"e:\\cpp\\data\\ring000.txt");
if((fp2=fopen(resn,"a"))==NULL)
{
printf("can not open result file:%s\n",resn);
exit(0);
}
}
result.b=data.B;
result.l=data.L;
result.h=data.H;
data.B=pi*data.B/180;
data.L=pi*data.L/180;
data.H=data.H-a;
N=a/sqrt(1-e*e*sin(data.B)*sin(data.B));
result.x=(N+data.H)*cos(data.B)*cos(data.L);
result.y=(N+data.H)*cos(data.B)*sin(data.L);
result.z=(N*(1-e*e)+data.H)*sin(data.B);
fprintf(fp2,"%12.4f,%12.4f,%12.4f,%12.4f,%12.4f,%12.4f\n",result.b,result.l,result.h,result.x,result.y,result.z);
}}
fclose(fp1);
fclose(fp2);
fclose(fp3);
}