In load, when I assign the word I loaded from dictionary to new_node, I originally used
new_node->word = new_word
but an error told me that it is non assignable. However, when I use strcpy it works, but why? Thanks in advance.
CS50 Stack Exchange is a question and answer site for students of Harvard University's CS50. It only takes a minute to sign up.
Sign up to join this communityThis is the way strings work in C. Because a string in C is an array of chars, you can only initialize it during the declaration. If you want to change its contents after the initialization, or if you declared it without initialization, you need to manually copy the new string into the old string char by char, and to not forget about the final '\0'. Or you can use strcpy(), which basically does this all for you.