need some help on my link list
hi, im trying to read a string one at a time from a text file separated by space and put it into a link list. i think the part where i read the file and put the string into the link list is wrong. can anyone correct me?
Code:
struct fileEntry{
char *entry;
struct fileEntry *next;
};
int main(){
char entryRecord[50];
FILE *myfile;
myfile = fopen("/home/user/file");
struct fileEntry *headNode, *tailNode;
headNode = NULL;
tailNode = NULL;
//allocate memory
headNode = (struct fileEntry*)malloc(sizeof(struct fileEntry));
headNode.entry = NULL;
headNode.next = NULL;
while(fgets(entryRecord, sizeof(entryRecord), myfile))
{
headNode.entry = entryRecord;
headNode.next = NULL;
//set tail node to become head node
tailNode = headNode;
headNote.entry = NULL;
headNote.next = NULL;
}
}