> i did not understand what is the mean of the function add_to_list
> can you explain me ?
It means take this code, and move it into a separate function called add_to_list
Code:
list *node = malloc(sizeof(list));
node->string = strdup(line);
node->next = null;
if (head == null) {
current = head = node;
}
else {
current = current->next = node;
> line 19-25 need to convert for 2 arrays (i dont know how to do it with linked list)
It would be better just to say that.
Code:
int read_file(char * filename) {
FILE *fp;
char line[128];
LIST *head = NULL;
fopen_s(&fp, filename, "r");
if (fp == NULL)
return 0;
while (fgets(line, sizeof(line), fp)) {
// extract the useful information from line, and append a
// suitably allocated LIST element containing that information
// to the end of the list identified as 'head'.
head = add_to_list(head, line);
}
fclose(fp);
printf("thermic table\nx y\n====== ======\n");
print_list(head);
free_list(head);
return 1;
}
What does your 'LIST' typedef look like?