- 论坛徽章:
- 0
|
自己写的处理数据文件的小程序,查错查到最后发现fscanf根本不工作,实在找不出问题所在,把程序和数据文件都贴出来,肯请大家帮忙解决!
编译环境:devcpp4.9.9.2
//代码文件:main.cpp
#include <iostream>;
#include <stdlib.h>;
using namespace std;
int main(int argc, char *argv[])
{
void merge_zone_fcs(char *);
merge_zone_fcs(argv[1]);
system(" AUSE" ;
return 0;
}
void merge_zone_fcs(char *well)
{
FILE* fp_in1, *fp_in2, *fp_out;
char *fn_in1=new char[20];
char *fn_in2=new char[20];
char *fn_out=new char[20];
char *fcs_name = new char[20];
int microfcs_code=0;
int zonecode1=0,zonecode2=0;
double f_top=0;
double z_top1=0,z_top2=0;
double depth=0; //f_top:facies top, z_top: zone top
bool outofzone=true, zone_is_used=true, fcs_is_used=true;
strcpy(fn_in1, well);
strcpy(fn_in2, well);
strcpy(fn_out, well);
strcat(fn_in1, ".dep" ;
strcat(fn_in2, ".facies" ;
strcat(fn_out, ".par" ;
cout<<fn_in1<<endl<<fn_in2<<endl<<fn_out<<endl;
if((fp_in1=fopen(fn_in1,"r" )==NULL)
{
printf("Cannot Open inputfile %s\n",fn_in1);
exit(1);
}
if((fp_in1=fopen(fn_in2,"r" )==NULL)
{
printf("Cannot Open inputfile %s\n",fn_in2);
exit(1);
}
if((fp_out=fopen(fn_out,"w" )==NULL)
{
printf("Cannot Open outputfile %s\n",fn_out);
exit(1);
}
fscanf(fp_in2,"%s%lf",fcs_name,&f_top);
cout<<fcs_name<<endl<<f_top<<endl;
fscanf(fp_in1, "%lf%d", &z_top1, &zonecode1);
cout<<z_top1<<"\t"<<zonecode1<<endl;
fprintf(fp_out,"%12.3lf -999 -999\n",z_top1);
fclose(fp_in1);
fclose(fp_in2);
fclose(fp_out);
return;
}
数据文件:a.dep
1230 1
1250 2
a.facies
B 1234
C 1245 |
|