I want to read a sequence of digits, character by character, from a .txt file until I find a \n character, this is, until I find an enter. Then to transform each of those digits into integers, and make a linked list to store those integers. The number of digits is undefined, it can either be 1 or 1 000 000. This is what I have done so far, but I just can't get my head around on how to transform them into ints, how make the actual list and then print it.
void make_seq_list ()
{
struct seq_node *seq_current = seq_head;
int digit_;
printf("sequence:\n");
while ( (digit_ = fgetc("fptr")) != '\n')
{
//???
}
}
This is how I defined each node for this list:
typedef struct seq_node //declaration of nodes for digit sequence list
{
int digit; //digit already as an int, not char as read from the file
struct seq_node *next;
} seq_node_t;
Note that in the txt file, the sequence is something like:
1 2 3 1 //it can go on indefinitely
/*something else*/
Thanks in advance.