Standard C++ Library Reference ISO/IEC (VERSION3)
You write %[ to store the matched input characters in an array object, followed by a terminating
null character. If you do not specify a field width w, then w has a large value. The match does
not skip leading white space. A sequence of up to w characters matches the conversion pattern
in the scan set that follows. To complete the scan set, you follow the left bracket ([) in the
conversion specification with a sequence of zero or more match characters, terminated by a
right bracket (]).
If you do not write a caret (^) immediately after the [, then each input character must match
one of the match characters. Otherwise, each input character must not match any of the match
characters, which begin with the character following the ^. If you write a ] immediately after
the [ or [^, then the ] is the first match character, not the terminating ]. If you write a minus
(-) as other than the first or last match character, an implementation can give it special
meaning. It usually indicates a range of characters, in conjunction with the characters
immediately preceding or following, as in 0-9 for all the digits.) You cannot specify a null
match character.
sscanf("129E-2", "%[54321]", &s[0]) stores "12"
For a wide stream, conversion occurs as if by repeatedly calling wcrtomb, beginning in the
initial conversion state.
swscanf(L"129E-2", L"%[54321]", &s[0]) stores "12"
You write %l[ to store the matched input characters in an array object, with elements of type
wchar_t, followed by a terminating null wide character. If you do not specify a field width w,
then w has a large value. The match does not skip leading white space. A sequence of up to w
characters matches the conversion pattern in the scan set that follows.
For a byte stream, conversion occurs as if by repeatedly calling mbrtowc, beginning in the
initial conversion state.
sscanf("129E-2", "%l[54321]", &s[0]) stores L"12"
swscanf(L"129E-2", L"%l[54321]", &s[0]) stores L"12"
You write %% to match the percent character (%). The function does not store a value.
sscanf("% 0XA", "%% %i", &i) stores 10
See also the Table of Contents and the Index.
Copyright © 1989-2001 by P.J. Plauger and Jim Brodie. All rights reserved.