C examples for wchar.h:wscanf
function
<cwchar> <wchar.h>
Read formatted data from stdin
int wscanf (const wchar_t* format, ...);
Parameter | Description |
---|---|
format | a format string that follows the same specifications as format in scanf |
On success, the function returns the number of items of the argument list successfully filled.
On error, EOF is returned.
#include <wchar.h> int main ()//from ww w .j a v a 2s .c o m { wchar_t str [80]; int i; wprintf (L"Enter your family name: "); wscanf (L"%ls",str); wprintf (L"Enter your age: "); wscanf (L"%d",&i); wprintf (L"%ls, %d years old.\n",str,i); return 0; }
The following code reads integer.
#include <wchar.h> int main ()//www .j a va 2s . co m { wchar_t str [80]; int i; wprintf (L"Enter a hexadecimal number: "); wscanf (L"%x",&i); wprintf (L"You have entered %#x (%d).\n",i,i); return 0; }