Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- int main () {
- long long count[256];
- int x = 0;
- while (x<256) {
- count[x] = 0;
- x = x + 1;
- }
- std::ifstream randomData;
- randomData.open("/dev/urandom", std::ios::in | std::ios::binary);
- char myRandomChar;
- unsigned char myUnsignedRandomChar;
- long long runThruCount = 0;
- while (runThruCount<10000000000) {
- randomData.read(&myRandomChar, 1);
- myUnsignedRandomChar = (unsigned char)(myRandomChar);
- count[myUnsignedRandomChar]++;
- runThruCount++;
- }
- int id = 0;
- std::cout << "0: " << count[0] << "\n";
- while (id<=254) {
- id++;
- std::cout << id << "\t" << count[id] << "\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment