《C语言程序设计程设计》报告模板(李)
C语言程序设计课程设计报告
学 院:地球物理与石油资源学院
班 级: 物探11101
姓 名: 李继伟
学 号: 201105968
班内编号: 7
指导教师: 陈义群
完成日期: 2013年3月9日
一、课程设计题目和要求
题目:地震SEGY格式数据读写
日期:2013年2月25日至2013年3月10日
主要内容:
理解地震SEGY格式
使用结构体读取卷头和道头
高低字节序交换
二维动态数组
两种浮点格式数据读取
将读取的共炮记录保存为SURFER的GRD文本格式
要求:
运行结果以SURFER的图片形式提交
源代码格式规范
认真撰写C语言程序设计课程设计报告
独立完成,严禁抄袭,逐一验收
编译器:Microsoft Visual C++ 6.0
二、源代码
#include
#include
#include
#include “surfer.h”
#include “swap.h”
#include “float.h”
#include “binhead.h”
#include “tracehead.h”
void main ()
{
Struct SeismicSegyBinHead a; //卷头结构体
struct SeismicSegyTraceHead b; //道头结构体
unsigned int c; //无符号变量
FILE *fp; //文件指针变量
float k,**p;
int m,n,x;
fp=fopen("E:\\c语言\\地震SEGY格式数据读写\\数据\\float.sgy","rb");
if (fp==NULL)
{
printf("Cannot open file,press any key to exit!");
exit(0);
}
fseek(fp,3200,0); //开始读卷头
fread(&a,sizeof(a),1,fp);
swap_n32(&(a.jobid));
swap_n32(&(a.lino));
swap_n32(&(a.reno));
swap_n16(&(a.ntrpr));
swap_n16(&(a.nart));
swap_u16(&(a.hdt));
swap_u16(&(a.dto));
swap_u16(&(a.hns));
swap_u16(&(a.nso));
swap_n16(&(a.format));
swap_n16(&(a.fold));
swap_n16(&(a.tsort));
swap_n16(&(a.vscode));
swap_n16(&(a.hsfs));
swap_n16(&(a.hsfe));
swap_n16(&(a.hsfe));
swap_n16(&(a.hslen));
swap_n16(&(a.hstyp));
swap_n16(&(a.schn));
swap_n16(&(a.hstas));
swap_n16(&(a.hstae));
swap_n16(&(a.htatyp));
swap_n16(&(a.hcorr));
swap_n16(&(a.bgrcv));
swap_n16(&(a.rcvm));
swap_n16(&(a.mfeet));
swap_n16(&(a.polyt));
swap_n16(&(a.vpol));
fread(&b,sizeof(b),1,fp); //开始读道头
swap_n32(&(b.tracl));
swap_n32(&(b.tracr));
swap_n32(&(b.fldr));
swap_n32(&(b.tracf));
swap_n32(&(b.ep));
swap_n32(&(b.cdp));
swap_n32(&(b.cdpt));
swap_n16(&(b.trid));
swap_n16(&(b.nvs));
swap_n16(&(b.nhs));
swap_n16(&(b.duse));
swap_n32(&(b.offset));
swap_n32(&