Reputation: 485
I am trying to read an input file line by line and using sscanf
to check and extract it. But the lines, although they always have two terms per each, they can be differently formatted, e.g. the file may look like:
valueone 0
valuetwo 55
valuethree version
Had it been only formats of string followed by number, I could always scan as follows: (int test;
)
test = sscanf(line, "%s%f", title, &num)
but as shown above, sometimes the format of a line is %s%s
(e.g. 3rd line sscanf(line, "%s%s", title, strvalue)
), so how can I write the arguments of sscanf to allow for both kinds of line formats?
Upvotes: 0
Views: 146