r/cs50•
mathmagician95

Copying words from dictionary into nodes

I'm trying to implement speller's load function with a hash table, and I've encounterd a problem with putting words into their respective nodes. First I create an array of chars to temporarily store the word, like so: char* word[LENGTH + 1] = {}; Then I try to use the strcpy function to put it inside my node like so: strcpy(new_node->word, word); and I keep getting this error: incompatible pointer types passing 'char [46]' to parameter of type 'const char'. I kind of understand why this is happenning (simply the way that strcpy is defined, right?) but then I have no idea how to fix this. Any suggestions?

P.S. this is how I define a node at the beginning, just for clarity: typedef struct node { char word[LENGTH + 1]; struct node* next; } node;

Posted Sep 16, 2015, 7:21 AM UTC

22
Loading comments…