If there's a maximum expected length for
each line in the text file (say MAX_LNLEN), you could read lines one by one using for example...
Code:
fgets(buffer, MAX_LNLEN+1, fp)
with buffer declared as an array of MAX_LNLEN+1 characters (+1 is for '\0').
Now, if you use the second struct, you could simply...
Code:
sscanf(buffer, "%d %s", &node->key, node->info);
By using the first struct, things get a bit more complicated because you need to tokenize the buffer yourself (for example using strtok) and then count the length of the 2nd token, so you can allocate the required memory for node->info and copy the 2nd token into it.
Also, when freeing up your linked list, then for every node you should first free up node->info before freeing up the node itself. This wouldn't be necessary if you had chosen then 2nd struct.
Finally, if there is no expected maximum length for the lines in the file, then using fgets is not really an option. In that case you should read the file char by char and do all the housekeeping manually. However, if that's just a homework, I doubt this will be necessary.