typedef struct node {
struct node* next;
int hash;
symbol_t symbol;
} node_t;
typedef struct symbol {
char* name;
int addr;
} symbol_t;
Above are the definitions of two structs I am using. I'm trying to add a new node_t to a linked list. First, I allocate memory for the node_t:
node_t* newSymbol = malloc(sizeof(node_t));
Then, the node_t should contain a nested struct (symbol). I try to modify the name property (string) inside the symbol struct that's in the node_t:
newSymbol->symbol.name = name;//name is a parameter to function I'm in
I try to initialize the name and the addr inside of the symbol nested struct; however, I am getting this error:
warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers] newSymbol->symbol.name = name;
^
I've tried multiple ways to modify data in the nested symbol struct, but it either throws the error I listed above or results in a segmentation fault. I'm not sure what I'm doing wrong. Thanks in advance for any help.
constpointer to a non-const pointer.