Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void push_history(char **args)
- {
- int args_length = 0;
- for(int i = 0; args[i] != NULL; i++)
- args_length++;
- char ** hard_copy = new char*[args_length];
- for(int i = 0; i < args_length; i++)
- hard_copy[i] = args[i];
- vector_length++;
- hist.push_back(hard_copy);
- }
- //print history
- void printHistory()
- {
- int count = 0;
- string str_cat = "";
- if(vector_length <= 10)
- {
- for(int i = 0; i < vector_length; i++)
- {
- str_cat = "";
- for(int ii = 0; hist[i][ii] != NULL; ii++)
- {
- str_cat += hist[i][ii];
- str_cat += " ";
- }
- cout << (count+1) << " " << str_cat << endl;
- count++;
- }
- }
- //more than 10 commands in history
- else
- {
- for(int i = vector_length - 10; i < vector_length; i++)
- {
- str_cat = "";
- for(int ii = 0; hist[i][ii] != NULL; ii++)
- {
- str_cat += hist[i][ii];
- str_cat += " ";
- }
- cout << (count+1) << " " << str_cat << endl;
- count++;
- }
- }
- }
Add Comment
Please, Sign In to add comment