请教读取数据的问题

xiaoyao026 2003-04-14 07:23:24
我有一些数据文件,使用c++bulider来读取数据,根据数据来画图,下面是文件的数据格式,我不知怎样通过读取函数来操作,我想把读出的数据存入一个动态数组。请各位帮帮忙,万分感谢



savepara paratosave
chapara (0 to 31) channel-parameter
strip strip-parameter
datasofdrawing integer
validchannels byte
currentpassno long
dataofsavefile string*10
timeofsavefile string*8
数据
type paratosave
first channel byte
last channel byte
fregnence long
gains byte
end type
type channel-parameter
channelno byte
signalname string*25
signalunit string*10
colibrateratio single
scaleofsignal single
basedata single
end type
type strip-parameter
lengthofstrip integer
widthofstrip integer
heightofstrip integer
material string*15
batch string*20
no string*8
end type
...全文
34 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
xiaoyao026 2003-04-15
  • 打赏
  • 举报
回复
修正一下结构:channelparameter chapara[32];
也就是说有32个参数,每个参数包括上百个数值,我想读出每个参数包含的数值,存入一个数组,32个参数存入32个数组,请问该怎样做,谢谢!
c2y 2003-04-14
  • 打赏
  • 举报
回复
FILE * fp;
...
//一次读一条记录
paratosave tp;
fread(&tp,sizeof(tp),1,fp);
//读n调记录
paratosave tp[n];
fread(tp,sizeof(tp),n,fp);

xiaoyao026 2003-04-14
  • 打赏
  • 举报
回复
我在unit1.h中定义了如下结构,请看一下是否正确,那个chapara(0 to 31)如何定义
struct paratosave
{
byte firstchannel,lastchannel;
long fregnence;
byte gains;
};
struct channelparameter
{
byte channelno;
Char signalname[25];
Char signalunit[10];
Single colibrateratio,scaleofsignal,basedata;
};
struct stripparameter
{
int lengthofstrip,widthofstrip,heightofstrip;
char material[15],batch[20],no[8];
};
struct aldfileformat
{
paratosave savepara;
channelparameter chapara;
stripparameter strip;
int dataofdrawing;
byte validchannels;
char dataofsavefile[10],timeofsavefile[8];
long currentpassno;
};
这样定义完后,如何使用fread读出数据阿,给写一个例子,谢谢
c2y 2003-04-14
  • 打赏
  • 举报
回复
由于数据使用结构存储,每一条记录长度相同,使用随即方式读取数据就好。
xiaoyao026 2003-04-14
  • 打赏
  • 举报
回复
大家帮帮忙啊,十万火急,需要数据文件的我可以给你们,就是想读出数据画图
csdsq 2003-04-14
  • 打赏
  • 举报
回复
好象是证券分析类软件啊...

13,837

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧