tags:

views:

79

answers:

1

Hello,

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,

+2  A: 
%*[^=]

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

KennyTM
`[^` is described in the C standard available from http://www.open-std.org/jtc1/sc22/wg14/www/standards.html and isn't a POSIX extension.
Roger Pate