Reputation: 504
I am learning about sscanf
and came across a format string as below:
sscanf("%[^:]:%[^*=]%*[*=]%n",a,b,&c);
I understood the part %[^:]
means scan till a ':'
is encountered and assign it to a
.
:
in format string mean match for a ':'
.
But
I understood that %*d
mean suppress the assignment till a number is encountered. But then %[^*=]
, what does the *
inside the []
mean?
%*[*=]
, is it like suppress the scanning till it encounters a =
. If it is so, is it equivalent to %[^=]
?
Upvotes: 2
Views: 200
Reputation: 4669
The *
inside square brackets is just a literal *.
This call to sscanf
will match everything up to a * or = in the second directive, and assign the result to b
. Then the third directive will grab all * or = characters, and throw away the result.
Upvotes: 1