Rallias

Untitled

Jul 14th, 2013
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3.  
  4. int main () {
  5. long long count[256];
  6. int x = 0;
  7. while (x<256) {
  8. count[x] = 0;
  9. x = x + 1;
  10. }
  11.  
  12. std::ifstream randomData;
  13. randomData.open("/dev/urandom", std::ios::in | std::ios::binary);
  14. char myRandomChar;
  15. unsigned char myUnsignedRandomChar;
  16.  
  17. long long runThruCount = 0;
  18. while (runThruCount<10000000000) {
  19. randomData.read(&myRandomChar, 1);
  20. myUnsignedRandomChar = (unsigned char)(myRandomChar);
  21. count[myUnsignedRandomChar]++;
  22. runThruCount++;
  23. }
  24.  
  25. int id = 0;
  26. std::cout << "0: " << count[0] << "\n";
  27. while (id<=254) {
  28. id++;
  29. std::cout << id << "\t" << count[id] << "\n";
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment