IHYPRESS PROGRAMMING
Tutorials and C programs with code and output for beginners
c programming
HOME | ASP | C | CSS | GNUPLOT | HTML | JAVASCRIPT | PERL | PHP | PYTHON | RUBY | SVG
CSelection Structures : Random Number and Unicode
<03.11>
/* rolling one die and printing it with unicode characters */ #include <stdio.h> #include <time.h> #include <stdlib.h> #include <wchar.h> #include <locale.h> int main(void) { int die; // the die unicode characters wchar_t one = 0x2680; wchar_t two = 0x2681; wchar_t three = 0x2682; wchar_t four = 0x2683; wchar_t five = 0x2684; wchar_t six = 0x2685; srand (time(NULL)); // seeding random generator die = rand() % 6 + 1; // random number between 1 and 6 setlocale(LC_CTYPE, ""); // setting locale for unicode // printing the dice with wprintf if (die == 1) wprintf(L"%lc\n", one); if (die == 2) wprintf(L"%lc\n", two); if (die == 3) wprintf(L"%lc\n", three); if (die == 4) wprintf(L"%lc\n", four); if (die == 5) wprintf(L"%lc\n", five); if (die == 6) wprintf(L"%lc\n", six); return (0); }
Hergestellt in Deutschland / Made in Germany
COPYRIGHT © 2015-2025 IHY PRESS Frankfurt am Main 60329 Deutschland