Having a problem with assigning a string in this linked list, any ideas?
the line that reports an error is highlighted in red.

I would expect this to work as variable 'name' is a char array and i am simply assigning the string "Vin" to it.


typedef struct // TV Guide entry struct declaration
        char name[50];
        char day[10];
        int time;

typedef struct LinkedListNode // LinkedListNode declaration
       Entry* entry; // Points to Entry struct
       struct LinkedListNode* next; // Points to the next node

typedef struct // LinkedList declaration
        int listLength;
        LinkedListNode* head; // Points to first node of linkedlist

void createList() // Creates an empty linkedlist
     LinkedList* entryList;
     entryList = (LinkedList*)malloc(sizeof(LinkedList));
     entryList -> head = NULL;
     entryList -> listLength = 0;   

void insertFirst( LinkedList* entryList )
     	LinkedListNode* newNode;
	newNode = (LinkedListNode*)malloc(sizeof(LinkedListNode));
	newNode -> entry -> name = "Vin"; // <- NOT WORKING!
	newNode -> next = entryList -> head;

You're writing C which simulates a string with a character array. You can't use = to assign arrays. Look up string.h functions...

Thanks, ended up changing the line to:

strcpy( newNode->entry->name , "Vin" );
This question has already been answered. Start a new discussion instead.