运行到这里就出错了,报内存不能read。
CURVE_DATA *first_node=NULL;
CURVE_DATA *data_node=NULL;
data_head=first_head;
data_head和first_head是链表。
额- -!我是个小白,没有币给各位了,还请不吝赐教,谢谢了!
PS:这个能上传文件吗?
找到错的地方了,定义深度数组的大小定义小了,把ROW定义大点就行了。
float depth[ROW];
int lineNum=0;
lineNum=(maxDepth-minDepth)/delta;
int row=0;
for(row=0;row<lineNum;row++)
{
depth[row]=minDepth+delta*row;
}
first_head 没有分配地址,操作 NULL 无论是写、还是读都会出错的.
没有开辟内存空间。。。当然不能读写
指针没有开辟内存空间;最好把前面的代码贴上,这样才更好分析!
CURVE_HEAD *first_head=NULL;
CURVE_HEAD *data_head=NULL;
float delta=0.0;//曲线的采样长度
int num=0;
for(num=0;num<curveNum;num++)
{
data_head=new CURVE_HEAD;
data_head->position=curvePosition[num];//将曲线位置导入data_head
wisfile[j].seekg(curvePosition[num],ios::beg);
WIS_CHANNEL *channel;
channel= new WIS_CHANNEL;//wis通道
wisfile[j].read(reinterpret_cast<char *>(channel),sizeof(WIS_CHANNEL));
data_head->startMD=channel->DimInfo[0].StartVal;
delta=channel->DimInfo[0].Delta;
data_head->stopMD=channel->DimInfo[0].StartVal+delta*channel->DimInfo[0].MaxSamples;
int i=0;
for(i=0;i<16;i++)
{
data_head->Name[i]=curveName[num][i];
}
for(i=0;i<8;i++)
{
data_head->Unit[i]=channel->Unit[i];
}
strwisid.Format("StopMd:%f",data_head->stopMD);
data_head->next=first_head;
first_head=data_head;
}
//*************************判断曲线的最小初始深度和最大的最大深度********************
float minDepth=0.0;
float maxDepth=0.0;
minDepth=first_head->startMD;
maxDepth=first_head->stopMD;
int pointnum=0;
for(data_head=first_head;data_head!=NULL;data_head=data_head->next)
{
pointnum+=1;
if(minDepth>data_head->startMD)
{
minDepth=data_head->startMD;
}
if(maxDepth<data_head->stopMD)
{
maxDepth=data_head->stopMD;
}
}
float depth[ROW];
int lineNum=0;
lineNum=(maxDepth-minDepth)/delta;
int row=0;
for(row=0;row<lineNum;row++)
{
depth[row]=minDepth+delta*row;
}
//****************************************
CURVE_DATA *first_node=NULL;
CURVE_DATA *data_node=NULL;
data_head=first_head;
//***********************************************************
以上就是从data_head和first_head从定义开始到大概出错的地方了,
这不是作弊么,自己采纳自己的答复。建议CSDN处理。