c 读入文件
#include"stdio.h"#include "iostream.h"
void main(){
struct curveHead{
char cg;
char comName;
char curveName;
//short sCurveNum;
//short sReservation;
short sh;
char dls;
//short sh;
//float fl;
//charm_cWellName;
//charm_cCurveName;
float StartWellDepth;
float EndWellDepth;
float SamplingSpace;
int Reservation;
float fSampleNum;
charcReservation;
charcMoreCurve;
//float extent;
}head;
struct curveHead *p;
p=head;
//char ch;
//char extent;
//char cg;
//char comName;
//char curveName;
//char dls;
FILE *fp;
//short *sh;
//short sh;
//float fl;
//FILE *fpp;
//fpp=fopen("aa","w+");
if ((fp=fopen("LACBL2","rb"))==NULL)
printf("error");
//fseek(fp,4L,0);
//cout<<"sdfgfsdgfdsgfdsgfs";
//int j=sizeof(struct curveHead);
//cout<<j;
int i=fread(p,sizeof(struct curveHead),1,fp);
cout<<p->cg;
cout<<"\n";
cout<<p->comName;
cout<<"\n";
cout<<p->curveName;
cout<<"\n";
for(int q=0;q<20;q++){
cout<<p->dls;
cout<<"\n";
}
cout<<"\n";
cout<<p->sh;
cout<<"\n";
cout<<p->sh;
cout<<"\n";
cout<<p->StartWellDepth;
cout<<"\n";
//cout<<p->StartWellDepth;
cout<<p->EndWellDepth;
cout<<"\n";
cout<<p->SamplingSpace;
//cout<<p->SamplingSpace;
cout<<p->Reservation;
cout<<"\n";
cout<<p->fSampleNum;
cout<<"\n";
cout<<p->cReservation;
cout<<"\n";
cout<<p->cMoreCurve;
fseek(fp,496,0);
float data;
fread(data,64*5*4,1,fp);
for(int n=0;n<5;n++)
for(int m=0;m<64;m++){
cout<<data;
cout<<"\n";
}
//cout<<p->extent;
//FILE *fpp;
//if ((fpp=fopen("aaa.txt","w+"))==NULL)
//printf("error");
//fwrite(p->sh,4,1,fpp);
fclose(fp);
}
页:
[1]