Standard C++ Library Reference ISO/IEC (VERSION3)

You write %lc to store the matched input characters in an array object, with elements of type
wchar_t. If you specify no field width w, then w has the value one. The match does not skip
leading white space. Any sequence of w characters matches the conversion pattern. For a byte
stream, conversion occurs as if by repeatedly calling mbrtowc, beginning in the initial
conversion state.
sscanf("129E-2", "%lc", &c) stores L'1'
sscanf("129E-2", "%2lc", &c) stores L'1', L'2'
swscanf(L"129E-2", L"%lc", &c) stores L'1'
You write %d, %i, %o, %u, %x, or %X to convert the matched input characters as a signed
integer and store the result in an integer object.
sscanf("129E-2", "%o%d%x", &i, &j, &k) stores 10, 9, 14
You write %e, %E, %f, %g, or %G to convert the matched input characters as a signed fraction,
with an optional exponent, and store the result in a floating-point object.
sscanf("129E-2", "%e", &f) stores 1.29
You write %n to store the number of characters matched (up to this point in the format) in an
integer object. The match does not skip leading white space and does not match any input
characters.
sscanf("129E-2", "12%n", &i) stores 2
You write %p to convert the matched input characters as an external representation of a pointer
to void and store the result in an object of type pointer to void. The input characters must match
the form generated by the %p print conversion specification.
sscanf("129E-2", "%p", &p) stores, e.g. 0x129E
You write %s 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. Any sequence of
up to w non white-space characters matches the conversion pattern.
sscanf("129E-2", "%s", &s[0]) stores "129E-2"
For a wide stream, conversion occurs as if by repeatedly calling wcrtomb beginning in the
initial conversion state.
swscanf(L"129E-2", L"%s", &s[0]) stores "129E-2"
You write %ls 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. Any sequence of up to w non white-space characters matches the
conversion pattern. For a byte stream, conversion occurs as if by repeatedly calling mbrtowc,
beginning in the initial conversion state.
sscanf("129E-2", "%ls", &s[0]) stores L"129E-2"
swscanf(L"129E-2", L"%ls", &s[0]) stores L"129E-2"