Advertisement
Guest User

Untitled

a guest
Feb 16th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.76 KB | None | 0 0
  1. #include<iostream>
  2. #include<stdio.h>
  3. #include<string>
  4. #include<vector>
  5. using namespace std;
  6. void checkParser(int type, bool correct)
  7. {
  8.     if (correct)
  9.         cout << "parsing type: " << type << endl;
  10. }
  11. void parserFirstStep(string inputConsole)
  12. {
  13.     const vector<string> commandList = { "wc","egrep","ls","comm","tail","pwd","dc","man" };
  14.     int type = 0;
  15.     bool checkType = false;
  16.     unsigned int i = 0;
  17.     while((i < commandList.size())&& !checkType)
  18.     {
  19.         int position = inputConsole.find(commandList[i]);
  20.         if (position == 0)
  21.         {
  22.             type = i;
  23.             inputConsole.erase(0, commandList[i].length());
  24.             checkType = true;
  25.         }
  26.         i++;
  27.     }
  28.     checkParser(type, checkType);
  29. }
  30.  
  31. int main()
  32. {
  33.     string input;
  34.     getline(cin, input);
  35.     parserFirstStep(input);
  36.     system("pause");
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement