A well known function of the
scanf() functions is that you can pass a format to scan input according to this format.
I have a string (
sInput) as the following:
#something VAR1 this is a constant string //some comment
VAR1 is meant to be the name of the constant string
this is a constant.
Now I am scanning this string like this:
if(sscanf(sInput, "%*s %s %s", paramname, constantvalue) != 2) //do something
And of course, when I output
constantvalue I get:
But I would like to have
constantvalue to contain the string until two consecutive spaces are found (so it would contain the part
this is a constant string).
So therefore I tried:
sscanf(sInput, "%*s %s %[^( )]s", paramname, constantvalue) sscanf(sInput, "%*s %s %[^ ]s", paramname, constantvalue)
But without luck. Is there a way to achieve my goal with
sscanf()? Or should I implement another way of storing the string?