With the following code I keep getting the following errors:
hw4.c: In function âread_numberâ:
hw4.c:57: error: dereferencing pointer to incomplete type
hw4.c:58: error: dereferencing pointer to incomplete type
I've tried several different things to fix it but cannot figure it out. Linked lists are the only things I've had trouble with all year and I can never figure them out. Can someone please help me out with what is wrong with this code? Btw, all function prototypes cannot be changed.
Code:
typedef struct link_list list;
struct list
{
int data;
struct list *next;
};
list* read_number(char * str);
list* create_node(int data);
list* build_list(list * headptr, list *node);
list* insert_node(list * headptr, int x);
list* delete_node(list * headptr, int loc);
void write_output(list * headptr, char * str);
void print_list(list * headptr);
FILE * in;
FILE * out;
int main(int argc, char **argv)
{
FILE * out;
char * str;
list * lst;
int i;
if(argc != 3)
{
printf("Usage: <%s> <input file> <output file>\n", argv[0]);
return 0;
}
str = argv[1];
lst = read_number(str)
return 0;
}
list* read_number(char * str)
{
list *temp = malloc(sizeof(struct list));
list *head = NULL;
list *number;
int num;
in = fopen(str, "r");
while(!feof(in))
{
fscanf(in, "%d", &num);
temp->data = num;
temp->next = head;
}
return temp;
}