C Tutorial/Wide Character String/Read Wide Character String

Материал из C\C++ эксперт
Перейти к: навигация, поиск

Use wscanf() to read the data, reading the two strings as wide-character strings

#include <stdio.h>
#include <wchar.h>
int main(void)
{
  int SIZE = 20;
  int value_count = 0;
  wchar_t wword1[SIZE];
  wchar_t wword2[SIZE];
  printf("wide character:");
  value_count = wscanf(L"%l[abcdefghijklmnopqrstuvwxyz] %ls",
                          wword1, wword2);
  printf("\nwword1 = %ls   wword2 = %ls\n", wword1, wword2);
  return 0;
}
wide character:W
wword1 =    wword2 =