Why can't I assign a string of chars to the chars array that I have created in the struct node. I tried to follow Zamyla tutorial and it seemed to work in there but when I am trying to just do this assignment I am getting this error :
main.c:21:18: error: array type 'char [2]' is not assignable
cursor->word = "dsds";
Here comes my code.
typedef struct node
{
char word[2];
struct node* next;
}
node;
int main(int argc, char* argv[])
{
node* cursor = (node*) malloc(sizeof(node));
cursor->word = "dsds";
printf("%s",cursor->word[0]);
}
Can someone explain why please?
Just by the way this assigning would work if I tried to assign a single character like 'd' to the cursor->word[0] and than I would get a standard output of 'd' in the console.