Hey Everyone,
I'm having trouble with my code. It compiles fine, but when I try to run it, I get an error.
Insight: I'm trying to read numbers in from a FILE and put those numbers into the doubly linked list.
Code:
void CreateList(struct node *lnode, int m, FILE *fp1){
struct node *head, *tail;
fscanf(fp1, "%d", &m);
while(!feof(fp1)){
lnode = (struct node *)malloc(sizeof(struct node));
lnode->data = m;
if(head == NULL)
{
head = lnode;
lnode->back = NULL;
}
else {
tail->next = lnode;
lnode->back = tail;
}
tail = lnode;
lnode->next = NULL;
fscanf(fp1, "%d", &m);
}
}