Using sscanf to extract some values
gcc 4.4.2
I have the following code:
char channels[] = "NumberOfChannel = [2]";
sscanf(channels, "%*[^=]= %d", &chan);
I am wondering what this means. As far as I can tell.开发者_如何转开发 It is ignoring the equals sign.
'^ ignore the character ='
Would that be correct?
Many thanks,
%*[^=]
The [^=]
means match a string which contains no =
. This is a POSIX extension. The *
means discard the matched result.
(BTW, to correctly get chan
you need sscanf(channels, "%*[^=]= [%d]", &chan);
.)
精彩评论