I was just wondering how to do this because it's killing me.
In the "C" Language
With fscanf how can you possibly take a text file with the contents:
"a b 10 20 30 67
a b 20 30 77 64"
Where "a" and "b" are names and the numbers at the end have no limit to how many?
So that you can have a variable to store each name and each of the numbers?
fscanf("%s %s %d etc.") does not work because there is two lines
If the count of numbers is variable, you can't really do it with fscanf, unless you define a maximum count of numbers. Functions that deal with formatted text typically return the number of elements that matched the template string. You can use that number to determine how many numbers you parsed. But this is still a fixed approach. For a better approach, consider parsing the lines yourself, which is easy if you use strtok.
so what if you don't know how many numbers at the end there are and it isn't just 4 %d's
Each newline there is a different number e.g.
Pretend the file is:
"string string num num num
string string num num
string string num num num num num num"
but you don't know what the file looks like or how many of each thing there is except two strings.
But there can't be more than 10 on any line
>Pretend the file is:
>"string string num num num
>string string num num
>string string num num num num num num"
>With fscanf how can you possibly take a text file with the contents:
>"a b 10 20 30 67
>a b 20 30 77 64"
so i assumed the file was that