Format
#include <stdio.h> int wscanf(const wchar_t *format,...);
Language Level: ANSI
Threadsafe: Yes.
Description
The wscanf() function is equivalent to the fwscanf() function with the argument stdin interposed before the arguments of the wscanf() function.
Return Value
If an input failure occurs before any conversion, the wscanf() function returns the value of the macro EOF.
Otherwise, the wscanf() function returns the number of input items assigned. It can be fewer than provided for, or even zero, in the event of an early matching failure.
Example that uses wscanf()
This example scans various types of data.
#include <stdio.h> #include <wchar.h> int main(void) { int i; float fp; char c,s[81]; printf("Enter an integer, a real number, a character and a string : \n"); if (wscanf(L"%d %f %c %s", &i, &fp,&c, s) != 4) printf("Some fields were not assigned\n"); else { printf("integer = %d\n", i); printf("real number = %f\n", fp); printf("character = %c\n", c); printf("string = %s\n", s); } return 0; /******************************************************************** The output should be similar to: Enter an integer, a real number, a character and a string : 12 2.5 a yes integer = 12 real number = 2.500000 character = a string = yes ********************************************************************/ }
Related Information
(C) Copyright IBM Corporation 1992, 2006. All Rights Reserved.