Hi,
I have one text file and need to read parameters stored in each of the files's lines. First, I read the file line by line. All clear, I can use the sscanf without problem for one line but only when all the lines have the same number of parameters. The problem appears when the number of parameters in one line are different. For example:
PARAM1 PARAM2 PARAM3
PARAM1 PARAM2
PARAM1 PARAM2 PARAM3 PARAM4
The parameters are separated by space.
I can use the folowing function:
Code:
sscanf(line, "%s %s %s", s[1], s[2], s[2]);
but only for a fixed number of parameters on each line (3 in this example).
My question is:
How to use sscanf when the number of parameters in one line is different (3, 2, or 4) like in the PARAMS example above. I refer to sscanf because it's an elegant solution for my need if it can be used like this, but other approaches are welcome too!
Any help is appreciated!
Thanks!