history.c
const char *hist_search_cnum(int command_number)
{
    // TODO: Retrieves a particular command number. Return NULL if no match
    // found.

  // char* cmd = 0;
  

  struct fork_list_struct* curr_fork = {0};
  // cmd = realloc(cmd, strlen(curr_fork->cmd)*sizeof(char));
  // if(cmd == NULL){
  //   free(cmd);
  //   return NULL;
  // }

  curr_fork = nexth_fork;

  while(curr_fork != NULL) {
    if(curr_fork->index == command_number) {
      // cmd = realloc(cmd, strlen(curr_fork->cmd)*sizeof(char));
      //char* cmd_copy = cmd;
      return curr_fork->cmd;;
    }
    curr_fork = curr_fork->next_fork;
  }
  // free(cmd);
  return NULL;
}
/** hist_search_cnum
* to give command number and find relevant command using the command history number
* @ param command number
* @ return command
 */
hist_search_cnum
to give command number and find relevant command using the command history number
hist_search_cnum to give command number and find relevant command using the command history number
const char *hist_search_cnum(int command_number)
{
  struct fork_list_struct* curr_fork = {0};
  curr_fork = nexth_fork;
  while(curr_fork != NULL) {
    if(curr_fork->index == command_number) {
      return curr_fork->cmd;;
    }
    curr_fork = curr_fork->next_fork;
  }
  return NULL;
}
const char * hist_search_cnum ( int command_number ) { struct fork_list_struct * curr_fork = { 0 } ; curr_fork = nexth_fork ; while ( curr_fork != NULL ) { if ( curr_fork -> index == command_number ) { return curr_fork -> cmd ; ; } curr_fork = curr_fork -> next_fork ; } return NULL ; }
hist_search_cnum
to give command number and find relevant command using the command history number
hist_search_cnum to give command number and find relevant command using the command history number
// TODO: Retrieves a particular command number. Return NULL if no match // found. // char* cmd = 0; // cmd = realloc(cmd, strlen(curr_fork->cmd)*sizeof(char)); // if(cmd == NULL){ //   free(cmd); //   return NULL; // } // cmd = realloc(cmd, strlen(curr_fork->cmd)*sizeof(char)); //char* cmd_copy = cmd; // free(cmd);