src/nhl_scores.c
// Returns new allocated string that is the substring of str that
//   results from removing 'front' characters from the beginning
//   of the string and 'back' characters from the end
Returns new allocated string that is the substring of str that
results from removing 'front' characters from the beginning
of the string and 'back' characters from the end
Returns new allocated string that is the substring of str that results from removing ' front ' characters from the beginning of the string and ' back ' characters from the end
char *new_substring(char *str, int front, int back) {
  int str_len = strlen(str);
  int substring_len = str_len - front - back;
  char *substring = malloc(sizeof(char) * (substring_len + 1));
  if (!substring) {
    return NULL;
  }
  int i = front;
  for (int j = 0; j <= substring_len; j++) {
    substring[j] = str[i];
    i++;
  }
  substring[substring_len] = '\0';
  return substring;
}
char * new_substring ( char * str , int front , int back ) { int str_len = strlen ( str ) ; int substring_len = str_len - front - back ; char * substring = malloc ( sizeof ( char ) * ( substring_len + 1 ) ) ; if ( ! substring ) { return NULL ; } int i = front ; for ( int j = 0 ; j <= substring_len ; j ++ ) { substring [ j ] = str [ i ] ; i ++ ; } substring [ substring_len ] = ' \0 ' ; return substring ; }
Returns new allocated string that is the substring of str that
results from removing 'front' characters from the beginning
of the string and 'back' characters from the end
Returns new allocated string that is the substring of str that results from removing ' front ' characters from the beginning of the string and ' back ' characters from the end