int wscanf (const wchar_t* format, ...);
Read formatted data from stdin
Reads data from stdin and stores them according to the C wide string format into the locations pointed by the additional arguments.
The additional arguments should point to already allocated objects of the type specified by their corresponding format specifier within the format string.
The external representation of wide characters in stdin are multibyte characters: These are translated as if mbrtowc was called (using the stream's internal mbstate_t object).
This is the wide character equivalent of scanf (<cstdio>).
- C wide string that contains a format string that follows the same specifications as format in scanf (see scanf for details).
Notice though, that all format specifiers have the same meaning as in scanf; therefore, %lc shall be used to read a wide character (and not %c), as well as %ls shall be used for wide strings (and not %s).
- ... (additional arguments)
- Depending on the format string, the function may expect a sequence of additional arguments, each containing a pointer to allocated storage where the interpretation of the extracted characters is stored with the appropriate type.
There should be at least as many of these arguments as the number of values stored by the format specifiers. Additional arguments are ignored by the function.
On success, the function returns the number of items of the argument list successfully filled. This count can match the expected number of items or be less (even zero) due to a matching failure, a reading error, or the reach of the end-of-file.
If a reading error happens or the end-of-file is reached while reading, the proper indicator is set (feof or ferror). And, if either happens before any data could be successfully read, EOF is returned.
If an encoding error happens interpreting wide characters, the function sets errno to EILSEQ.
/* wscanf example */
int main ()
wchar_t str ;
wprintf (L"Enter your family name: ");
wprintf (L"Enter your age: ");
wprintf (L"Mr. %ls, %d years old.\n",str,i);
wprintf (L"Enter a hexadecimal number: ");
wprintf (L"You have entered %#x (%d).\n",i,i);
Enter your family name: Soulié
Enter your age: 29
Mr. Soulié, 29 years old.
Enter a hexadecimal number: ff
You have entered 0xff (255).
- Read formatted data from stdin (function
- Print formatted data to stdout (function
- Get wide string from stream (function