Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include "unistd.h"
- #include "vector"
- #include "map"
- #include "stdlib.h"
- #include "sstream"
- using namespace std;
- vector<string> mots;
- string m;
- bool fini = false;
- using Action= bool (*) (const vector<string>&);
- const std::map <string,Action> actions{
- {"exit",commande_exit},
- {"!",commande_exclamation},
- {"cd",commande_cd}
- };
- void cd(string path)
- {
- chdir(path.c_str());
- }
- string concat()
- {
- string commande = (mots[0]+" "+mots[1]+" "+mots[2]+" "+mots[3]);
- cout<<commande<<endl;
- return commande;
- }
- /*
- void afficherContenuMots()
- {
- for(string s : mots)
- {
- cout<< " " <<s<<endl;
- }
- }
- */
- vector<string> decouper(const string &ligne)
- {
- istringstream in(ligne);
- string m;
- while(in >> m)
- {
- mots.push_back(m);
- }
- return mots;
- }
- void commande_exit()
- {
- fini = true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement