Advertisement
Guest User

Untitled

a guest
Nov 21st, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.13 KB | None | 0 0
  1. #include <dirent.h>
  2. #include <iostream>
  3. #include <vector>
  4. #include <string>
  5. #include <cstdlib>
  6. #include <ctime>
  7. #include <conio.h>
  8.  
  9. using namespace std;
  10.  
  11. int main()
  12. {
  13.     srand(time(NULL));
  14.     string path;
  15.     struct dirent *dir;
  16.     vector<string> dirlist;
  17.  
  18.     cout << "Nudzi Ci sie? Podaj sciezke do folderu z grami: ";
  19.     cin >> path;
  20.     DIR *d = opendir(path.c_str());
  21.     while ((dir = readdir(d)) != NULL)
  22.     {
  23.         dirlist.push_back(dir -> d_name);
  24.     }
  25.  
  26.     path += "\SteamLibrary\SteamApps\common";
  27.     d = opendir(path.c_str());
  28.     while ((dir = readdir(d)) != NULL)
  29.     {
  30.         dirlist.push_back(dir -> d_name);
  31.     }
  32.     int n;
  33.     cout << "Ile chcialbys propozycji ziomeczku? ";
  34.     cin >> n;
  35.     cout << "Hmm... Proponuje zagrac w:" << endl;
  36.     do {
  37.         int temp = rand() % dirlist.size();
  38.         if (dirlist[temp] == "." || dirlist[temp] == ".." || dirlist[temp] == "SteamLibrary" || dirlist[temp] == "desktop.ini") {}
  39.         else
  40.         {
  41.             cout << dirlist[temp] << endl;
  42.             n--;
  43.         }
  44.     } while (n != 0);
  45.     getch();
  46.     closedir(d);
  47.     return(0);
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement