Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.90 KB | None | 0 0
  1. struct AbbrArray *getAllAbbrsArrayNew(const char *str)
  2. {
  3.     int size = INITIAL_CAPACITY;
  4.     struct Abbr *array = malloc(size * sizeof(struct Abbr));
  5.  
  6.     char string[strlen(str)];
  7.     for (int i = 0; i <= strlen(str); i++)
  8.     {
  9.         string[i] = str[i];
  10.     }
  11.     int index = IndexOfAbb(string);
  12.     int counter = 0;
  13.     while (index != -1)
  14.     {
  15.         index = IndexOfAbb(string);
  16.         getAbb(string, array[counter].source, size);
  17.         counter++;
  18.         if (counter > size)
  19.         {
  20.             size *= 2;
  21.             array = realloc(array, size * sizeof(struct Abbr));
  22.         }
  23.         while (isupper(string[index]))
  24.         {
  25.             index++;
  26.         }
  27.         copyOfRange(string, string, strlen(string), index);
  28.     }
  29.     struct AbbrArray *result = malloc(sizeof(struct AbbrArray));
  30.     result->array = array;
  31.     result->size = counter - 1;
  32.     return result;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement