J
John
struct pair_node
{
int i;
double d;
};
struct pair_node **x;
The following is what I want to create.
x -> [ ] -> (2,0.1) (3,0.2) (-1,?)
[ ] -> (2,0.1) (3,0.3) (4,-1.2) (-1,?)
[ ] -> (1,0.4) (-1,?)
[ ] -> (2,0.1) (4,1.4) (5,0.5) (-1,?)
[ ] -> (1,-0.1) (2,-0.2) (3,0.1) (4,1.1) (5,0.1) (-1,?)
// Do I need an allocation before this loop for x?
for(i = 0; i < N; ++i){
//dumps core on the following line, anyone can help me why?
// am i missing something?
nprob.x = (struct pair_node *)malloc(sizeof(struct
pair_node)*D);
for(j = 0; j < D; ++j){
(nprob.x[j]).i = j;
(nprob.x[j]).d = w[j];
}
}
{
int i;
double d;
};
struct pair_node **x;
The following is what I want to create.
x -> [ ] -> (2,0.1) (3,0.2) (-1,?)
[ ] -> (2,0.1) (3,0.3) (4,-1.2) (-1,?)
[ ] -> (1,0.4) (-1,?)
[ ] -> (2,0.1) (4,1.4) (5,0.5) (-1,?)
[ ] -> (1,-0.1) (2,-0.2) (3,0.1) (4,1.1) (5,0.1) (-1,?)
// Do I need an allocation before this loop for x?
for(i = 0; i < N; ++i){
//dumps core on the following line, anyone can help me why?
// am i missing something?
nprob.x = (struct pair_node *)malloc(sizeof(struct
pair_node)*D);
for(j = 0; j < D; ++j){
(nprob.x[j]).i = j;
(nprob.x[j]).d = w[j];
}
}