开发者

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);.)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜