M
M A
Hi,
Please see following code.
It gives me segmentation fault when I try to add element to the list
on the very last line. I am not sure why the "bm" list inside MyStruct
is not getting initialized? What can I do to initialize it?
Thanks.
-------------------------------------------
#include <stdio.h>
#include <list>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
struct row {
int rowid;
char *data;
bool operator<(const struct row &a) const {
return (this->rowid < a.rowid);
};
};
typedef struct {
list<struct row> bm;
vector<struct row> vbm;
} MyStruct;
typedef struct pattern {
int nodenum; // unique in the graph
MyStruct ms;
} TP;
int main(int args, char **argv)
{
TP *tp = (TP *) malloc (sizeof(TP));
struct row r1 = {1, (char *)"xyz"};
tp->ms.bm.push_back(r1);
}
-------------------------------------------
Please see following code.
It gives me segmentation fault when I try to add element to the list
on the very last line. I am not sure why the "bm" list inside MyStruct
is not getting initialized? What can I do to initialize it?
Thanks.
-------------------------------------------
#include <stdio.h>
#include <list>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
struct row {
int rowid;
char *data;
bool operator<(const struct row &a) const {
return (this->rowid < a.rowid);
};
};
typedef struct {
list<struct row> bm;
vector<struct row> vbm;
} MyStruct;
typedef struct pattern {
int nodenum; // unique in the graph
MyStruct ms;
} TP;
int main(int args, char **argv)
{
TP *tp = (TP *) malloc (sizeof(TP));
struct row r1 = {1, (char *)"xyz"};
tp->ms.bm.push_back(r1);
}
-------------------------------------------