Sha256: 740b5e85f6b363c083cc216aedc296d2909d3882ab85bd2360d8efe1093575e5

Contents?: true

Size: 771 Bytes

Versions: 133

Compression:

Stored size: 771 Bytes

Contents

#include <stdlib.h>
#include <string.h>
#include <stdio.h>

#include "series.h"

series_results_t series(char *input_text, unsigned int substring_length)
{
   int substring_count = strlen(input_text) - (substring_length - 1);
   series_results_t results;

   memset(&results, 0, sizeof(results));
   if ((substring_count > 0) && (substring_length > 0)) {
      results.substring_count = substring_count;
      results.substring = malloc(sizeof(char *) * substring_count);
      for (int index = 0; index < substring_count; index++) {
         results.substring[index] =
             malloc(sizeof(char) * (substring_length + 1));
         sprintf(results.substring[index], "%.*s", substring_length,
                 &input_text[index]);
      }
   }
   return results;
}

Version data entries

133 entries across 133 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/c/exercises/series/src/example.c
trackler-2.2.1.179 tracks/c/exercises/series/src/example.c
trackler-2.2.1.178 tracks/c/exercises/series/src/example.c
trackler-2.2.1.177 tracks/c/exercises/series/src/example.c
trackler-2.2.1.176 tracks/c/exercises/series/src/example.c
trackler-2.2.1.175 tracks/c/exercises/series/src/example.c
trackler-2.2.1.174 tracks/c/exercises/series/src/example.c
trackler-2.2.1.173 tracks/c/exercises/series/src/example.c
trackler-2.2.1.172 tracks/c/exercises/series/src/example.c
trackler-2.2.1.171 tracks/c/exercises/series/src/example.c
trackler-2.2.1.170 tracks/c/exercises/series/src/example.c
trackler-2.2.1.169 tracks/c/exercises/series/src/example.c
trackler-2.2.1.167 tracks/c/exercises/series/src/example.c
trackler-2.2.1.166 tracks/c/exercises/series/src/example.c
trackler-2.2.1.165 tracks/c/exercises/series/src/example.c
trackler-2.2.1.164 tracks/c/exercises/series/src/example.c
trackler-2.2.1.163 tracks/c/exercises/series/src/example.c
trackler-2.2.1.162 tracks/c/exercises/series/src/example.c
trackler-2.2.1.161 tracks/c/exercises/series/src/example.c
trackler-2.2.1.160 tracks/c/exercises/series/src/example.c