Advertisement
Guest User

Untitled

a guest
Dec 21st, 2019
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.66 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <fstream>
  4. #include <stdio.h>
  5. #include <Windows.h>
  6. #include <filesystem>
  7. #define WINDOWS
  8. #ifdef WINDOWS
  9. #include <direct.h>
  10. #define GetCurrentDir _getcwd
  11. #else
  12. #include <unistd.h>
  13. #define GetCurrentDir getcwd
  14. #endif
  15.  
  16. using namespace std::experimental::filesystem;
  17. using namespace std;
  18. ifstream read("data.in");
  19. ofstream write("data.in", ios_base::app);
  20. std::string GetCurrentWorkingDir(void) {
  21.     char buff[FILENAME_MAX];
  22.     GetCurrentDir(buff, FILENAME_MAX);
  23.     std::string current_working_dir(buff);
  24.     return current_working_dir;
  25. }
  26.  
  27.  
  28. void about()
  29. {
  30.     cout << "TerminalS v0.1 BETA\n";
  31. }
  32.  
  33.  
  34. void check(char msg[1000])
  35. {
  36.     if (strcmp(msg,"about")==0)
  37.         about();
  38.     else
  39.         if (strcmp(msg,"exit")==0)
  40.             system("pause");
  41.         else
  42.             system(msg);
  43. }
  44.  
  45.  
  46. void create_user()
  47. {
  48.     string usr1, pwd1;
  49.     cout << "Your username will be: ";
  50.     cin >> usr1;
  51.     cout << "\nYour password will be: ";
  52.     cin >> pwd1;
  53.  
  54.     write << usr1 << " " << pwd1 << endl;
  55. }
  56. char msg[1000];
  57. string ver,usr,pwd,ac;
  58. int main()
  59. {
  60.     //system("Color 0A");
  61.     cout << "Do you have an account? y/n\n";
  62.     cin >> ac;
  63.     if (ac == "n") {
  64.         create_user();
  65.         while (strcmp(msg,"exit")!=0)
  66.         {
  67.            
  68.             cout << GetCurrentWorkingDir() << ">> ";
  69.             cin >> msg;
  70.             check(msg);
  71.         }
  72.     }
  73.     if(ac == "y")
  74.     {
  75.         cout << "Username: ";
  76.         cin >> usr;
  77.         cout << "\nPassword: ";
  78.         cin >> pwd;
  79.         while (getline(read, ver))
  80.             if (usr + " " + pwd != ver)
  81.                 cout << "";
  82.             else
  83.                 while (strcmp(msg, "exit") != 0)
  84.                 {
  85.                     cout << GetCurrentWorkingDir() << ">> ";
  86.                     cin >> msg;
  87.                     check(msg);
  88.                 }
  89.     }
  90.     read.close();
  91.     write.close();
  92.     return 0;
  93. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement