📅  最后修改于: 2020-09-25 09:44:05             🧑  作者: Mango
vfwscanf() 函数在
int vfwscanf( FILE* stream, const wchar_t* format, va_list vlist );
所述vfwscanf() 函数从该文件读取流的数据stream
通过所定义和存储的值到相应位置vlist
。
#include
#include
#include
#include
void read( FILE *fp, const wchar_t* format, ... )
{
va_list args;
va_start (args, format);
vfwscanf (fp, format, args);
va_end (args);
}
int main ()
{
setlocale(LC_ALL, "en_US.UTF-8");
wchar_t symbol[] = L"\u0915\u0916\u0917\u0918\u0919";
wchar_t names[5][5] = {L"Ka", L"Kha", L"Ga", L"Gha", L"Nga"};
FILE *fp = fopen("example.txt","w+");
for (int i=0; i<5; i++)
fwprintf(fp, L"%lc %ls ", symbol[i], names[i]);
rewind(fp);
wchar_t ch, str[5];
for (int i=0; i<5; i++)
{
read(fp, L"%lc %ls ", &ch, str);
wprintf(L"%lc - %ls\n", ch, str);
}
fclose(fp);
return 0;
}
运行该程序时,可能的输出为:
क - Ka
ख - Kha
ग - Ga
घ - Gha
ङ - Nga