history.c
const char *hist_search_prefix(char *prefix)
{
    // TODO: Retrieves the most recent command starting with 'prefix', or NULL
    // if no match found.
  char *cmd;
  const char *const_cmd;
  struct fork_list_struct* curr_fork = nexth_fork;
  while (curr_fork != NULL) {
    if(strncmp(curr_fork->cmd, prefix, strlen(prefix)-1) == 0) {
      //cmd = realloc(cmd, strlen(curr_fork->cmd)*sizeof(char));
      cmd = curr_fork->cmd;
      const_cmd = cmd;
      return const_cmd;
    }
    curr_fork = curr_fork->next_fork;
  }
  return NULL;
}
/** hist_search_prefix
* to search prefix and find relevant command using the command history
* @ param prefix e.g hi 
* @ return command e.g. history
 */
hist_search_prefix
to search prefix and find relevant command using the command history
hist_search_prefix to search prefix and find relevant command using the command history
const char *hist_search_prefix(char *prefix)
{
  char *cmd;
  const char *const_cmd;
  struct fork_list_struct* curr_fork = nexth_fork;
  while (curr_fork != NULL) {
    if(strncmp(curr_fork->cmd, prefix, strlen(prefix)-1) == 0) {
      cmd = curr_fork->cmd;
      const_cmd = cmd;
      return const_cmd;
    }
    curr_fork = curr_fork->next_fork;
  }
  return NULL;
}
const char * hist_search_prefix ( char * prefix ) { char * cmd ; const char * const_cmd ; struct fork_list_struct * curr_fork = nexth_fork ; while ( curr_fork != NULL ) { if ( strncmp ( curr_fork -> cmd , prefix , strlen ( prefix ) - 1 ) == 0 ) { cmd = curr_fork -> cmd ; const_cmd = cmd ; return const_cmd ; } curr_fork = curr_fork -> next_fork ; } return NULL ; }
hist_search_prefix
to search prefix and find relevant command using the command history
hist_search_prefix to search prefix and find relevant command using the command history
// TODO: Retrieves the most recent command starting with 'prefix', or NULL // if no match found. //cmd = realloc(cmd, strlen(curr_fork->cmd)*sizeof(char));