c 读入文件

#include "stdio.h"
#include "iostream.h"
void main(){
struct curveHead{
char cg[4];
char comName[80];
char curveName[80];
//short sCurveNum;
//short sReservation;
short sh[2];
char dls[20][4];
//short sh[2];
//float fl[3];
//char m_cWellName[80];

//char m_cCurveName[80];
float StartWellDepth;
float EndWellDepth;
float SamplingSpace;
int Reservation;
float fSampleNum;
char cReservation[8];
char cMoreCurve[220];
//float extent[200000];

}head[1];
struct curveHead *p;
p=head;

//char ch[80];
//char extent[200000];
//char cg[4];
//char comName[80];
// char curveName[80];
//char dls[4];
FILE *fp;
//short *sh;
// short sh[2];
//float fl[3];

// 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[q];
cout<<"\n";
}
cout<<"\n";
cout<<p->sh[0];
cout<<"\n";
cout<<p->sh[1];
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[5][64];
fread(data,64*5*4,1,fp);
for(int n=0;n<5;n++)
for(int m=0;m<64;m++){
cout<<data[n][m];
cout<<"\n";
}
//cout<<p->extent[145000];
// FILE *fpp;

//if ((fpp=fopen("aaa.txt","w+"))==NULL)
// printf("error");
// fwrite(p->sh,4,1,fpp);


fclose(fp);



}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值