我试图从/dev/urandom
获取一个宽字符串,但STDOUT
上没有任何或一些短暂的奇怪结果。我今天需要解决这个问题。请帮我!这有什么不对......
#include <stdio.h>
#include <wchar.h>
#include <locale.h>
int main(){
setlocale(LC_ALL, "");
wchar_t text[100];
FILE *urandom;
int x = 5;
urandom = fopen("/dev/urandom", "r");
while(x--){
fgetws(text, 100, urandom);
fwprintf(stdout, L"%ls\n", text);
//fputws(text, stdout);
}
fclose(urandom);
return 0;
}
编辑:
THIS IS WHAT I SHOULD GET(使用normal char[], fgets, fputs
):
THIS IS WHAT I'M GETTING(使用wchar_t[], fgetws, fwprintf/fputws
):