海运东西到日本:c程序求教

来源:百度文库 编辑:杭州交通信息网 时间:2024/05/08 18:52:18
请问file1.c为什么打不开?(路径是正确的) 谢谢了先!
#include<stdio.h>
#include<math.h>
struct PX_11
{char st[7];
char TIME[7];
char LAT[10];
char LON[10];
char T[8];
char AP[12];
char RH[10];
char WD[11];
char WV[5];
}PX;
main()
{long j;
long i;
double f1,f2;
FILE *fp1,*fp2;
if((fp1=fopen("sc05111920.000","r"))==NULL)
{printf("can not open file1\n");
exit(0);}
if((fp2=fopen("px123.12","w"))==NULL)
{printf("can not open file2\n");
exit(0);}

j=0;
i=0;
fread(&PX,79,1,fp1);
fwrite(&PX,79,1,fp2);

while(!feof(fp1))
{

fread(&PX,sizeof(struct PX_11),1,fp1);
if(!feof(fp1))
{
f1=atof(PX.LAT);
f2=atof(PX.LON);
printf("searching...");
if(f1==120.58&&f2==35.66)
{fwrite(&PX,sizeof(struct PX_11),1,fp2);
j++;

}
i++;

}
}
printf("whole numble=%ld need numble=%ld\n",i,j);
printf("press any key to continue\n");
fclose(fp1);fclose(fp2);
getch();

}
难道是编译平台的问题? 我在 tc for windows上不能打开文件但是在Borland C++ v5.02平台上却可以正常运行.

路径对不对啊,

估计可能是路径不对,你用GetLastError()看看是什么错误,或者直接用完整的路径名再试试看