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
%*dmean 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%[^=]?
The
*inside square brackets is just a literal *.This call to
sscanfwill match everything up to a * or = in the second directive, and assign the result tob. Then the third directive will grab all * or = characters, and throw away the result.