#include "stdlib.h"
#include "stddef.h"
#include "string.h"
#include "ctype.h"
#include "stdio.h"
#include "math.h"
#include "assert.h"
struct ArcBox
{
int tail, head;
struct ArcBox *hlink , *tlink;
}ArcBox;
struct FeaNode
{
char feaname[30];
int type;
union range
{
char *c_range[70];
int i_range[70];
double d_range[70];
}range;
int indegree;
int rangenum;
struct ArcBox *parent , *child;
}FeaNode;
struct BayesNetwork
{
struct FeaNode *fealist;
int feanum, arcnum;
}BayesNetwork;
struct FeaNode fealist[5]=
{{"land",0,{"0","1"},0,2,NULL,NULL},
{"wrong_fragment",1,{0},0,2,NULL,NULL},
{"urgent",1,{0},0,2,NULL,NULL},
{"hot",1,{0},0,2,NULL,NULL},
{"num_failed_logins",1,{0},0,2,NULL,NULL}};
void InitNB(struct BayesNetwork *nb)
{
fealist[1].range.i_range[0]=0;
fealist[1].range.i_range[1]=1;
fealist[2].range.i_range[0]=0;
fealist[2].range.i_range[1]=1;
fealist[3].range.i_range[0]=0;
fealist[3].range.i_range[1]=1;
fealist[4].range.i_range[0]=0;
fealist[4].range.i_range[1]=1;
nb->fealist=fealist;
nb->feanum=5;
nb->arcnum=0;
}
void TestInitNB(struct BayesNetwork *nb)
{
struct FeaNode *p;
InitNB(nb);
p=nb->fealist;
while(p)
{
printf("%s\t%d\t%d\t%d\n",p->feaname,p->type,p->indegree,p->rangenum);
p++;
}
printf("feature number = %d\n",nb->feanum);
printf("arc number = %d\n",nb->arcnum);
}
void main()
{
struct BayesNetwork *nb=NULL;
TestInitNB(nb);
}
问题可能处在nb的初始化的分配空间上,但是具体哪里有问题呢?请教大家,我真是头疼死了,多谢了!