Right, I have to, for a assignment write a translator that translates Linear Temporal Logic formulae into Buchi automata in C.
Now part of what I have at the moment is:
Node->incoming; new; old and next must all be sets of strings. And I must be able to add to them. _node_Set must be an array of Nodes to which I can add.
My problem is, as it is here it compiles, but when I run it it throws a SIGSEGV when it gets to *(node->incoming) = _inc; in newNode();
As you can see I have no clue how to program in this language, my experience is with C++ and I'm missing many of its build-in features.
Please help.
Now part of what I have at the moment is:
Code:
typedef struct Node { char *name; char **incoming; char **new; char **old; char **next; } Node; Node *newNode(char *_inc, char *_new, char *_old, char *_next) { Node *node = malloc(sizeof(Node)); node->name = "Node" + j++; *(node->incoming) = _inc; *(node->new) = _new; *(node->old) = _old; *(node->next) = _next; return(node); } Node **expand(Node *_node, Node **_nodes_Set) { int a = 0; if (_node->new == NULL) { while (_nodes_Set[a] != NULL) { if ((_nodes_Set[a]->old == _node->old) && (_nodes_Set[a]->next = _node->next)) { *(_nodes_Set[a]->incoming + 1) = *_node->incoming; return(_nodes_Set); } else { *(_nodes_Set + 1) = _node; return(expand(newNode(_node->name, (char *)_node->next, NULL, NULL), _nodes_Set)); } a++; } } }
My problem is, as it is here it compiles, but when I run it it throws a SIGSEGV when it gets to *(node->incoming) = _inc; in newNode();
As you can see I have no clue how to program in this language, my experience is with C++ and I'm missing many of its build-in features.
Please help.
Comment