dimanche 17 janvier 2016

Getting wide character string from /dev/urandom on linux

I'm trying to get a wide character string from /dev/urandom but there is nothing or some short strange results on STDOUT. I need to solve this problem today. Please help me! What's wrong with it...

#include <stdio.h>
#include <wchar.>

int main(){

setlocale(LC_ALL, "");
wchar_t text[100];
FILE *urandom;
int x = 100;

urandom = fopen("/dev/urandom", "r");

    while(x--){

    fgetws(text, 100, urandom);
    fwprintf(stdout, L"%ls", text);
    //fputws(text, stdout);

    }

fclose(urandom);

return 0;

}




Aucun commentaire:

Enregistrer un commentaire