I have 2 structs defined as follows:
struct token
{
int tokenID;
char *tokenName;
char *tokenWord;
}token;
and
struct node
{
char nodeName[8]; // no token name longer than 8characters.
struct token *token1;
struct token *token2;
struct token *token3;
struct node *child1;
struct node *child2;
struct node *child3;
struct node *child4;
};
In my main I declare a new struct token and initialize it withsome values. When I try to string copy the values from the tokeninto the token1 member of a node like so:
strcpy(node->token1->tokenName,tk->tokenName);
I get a segmentation fault. Any thoughts on why?
Answer
Segmentation faults occur due to a faulty access.
The reasons for could to fail may
OR
OR