Reads in formatted data from a wide-character string #include <wchar.h> int swscanf ( const wchar_t * restrict wcs , const wchar_t * restrict format , ... ); The swscanf( ) function is similar to wscanf( ), except that it reads its input from the wide-character string addressed by the first argument, wcs, rather than from stdin. If swscanf( ) reads to the end of the string, it returns the value EOF. Exampledouble price = 0.0; wchar_t wstr[ ] = L"Current price: $199.90"; swscanf( wstr, L"%*[^$]$%lf", &price); // Read price from string. price *= 0.8; // Apply 20% discount. printf( "New price: $%.2lf\n", price); This code produces the following output: New price: $159.92 See Alsowscanf( ), fwscanf( ); wcstod( ), wcstol( ), and wcstoul( ); scanf( ), fscanf( ); fwprintf( ), wprintf( ), vfwprintf( ), and vwprintf( ); the example at wcsspn( ) in this chapter. |