title: counting sort with strings [core dumped]
body: <p>i need to write a counting sort algorithm which is sorting strings by the first letter (it doesn't matter if it's capital or small), but there is a Segmentation fault (core dumped) error after writing all strings. There are also some warnings (below)</p>
  
  <pre><code>aaa.c: In function ‘Count’:
  aaa.c:20:23: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
             C[i]=(char)((int)C[i]+(int)C[i-1]);
                         ^
  aaa.c:20:33: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
             C[i]=(char)((int)C[i]+(int)C[i-1]);
                                   ^
  aaa.c:20:15: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
             C[i]=(char)((int)C[i]+(int)C[i-1]);
                 ^
  aaa.c:22:25: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
                  B[(int)C[(int)A[j]]]=A[j];
                           ^
  aaa.c:22:18: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
                  B[(int)C[(int)A[j]]]=A[j];
                    ^
  aaa.c:23:18: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
                  C[(int)A[j]]=C[(int)A[j]]-1;
                    ^
  aaa.c:23:31: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
                  C[(int)A[j]]=C[(int)A[j]]-1;
  
  
  #include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  #include &lt;stdlib.h&gt;
  
  #define MaxStringLength 30
  #define MaxStringNumber 5
  #define NumberOfLetters 26
  
  char **A;
  char **B;
  char **C;
  
  void Count(char **A, char **B, int quantity){
          int i,j;
  
          for (i=1;i&lt;=NumberOfLetters;i++) C[i]=0;
          for (j=1;j&lt;=quantity;j++)
               C[A[j][1]-96] +=1;
          for (i=2;i&lt;=NumberOfLetters;i++)
            C[i]=(char)((int)C[i]+(int)C[i-1]);     
          for (j=MaxStringNumber;j&gt;0;j--){
                 B[(int)C[(int)A[j]]]=A[j]; 
                 C[(int)A[j]]=C[(int)A[j]]-1;
  
          }
  }
  
  void printing(char **array, int quantity){
          int i;
          for (i=1;i&lt;=quantity;i++)
                  printf("%s \n", array[i]);
  }
  
  void reading(char **array, int quantity){
          char word[MaxStringLength];
          int i;
          for (i=1;i&lt;=quantity; i++){
                  scanf("%s",word);
                  array[i] = (char*) malloc(sizeof(char)*MaxStringLength);
                  strcpy(array[i],word);
          }
  }
  
  int main(){
          A=(char**) malloc((MaxStringNumber+1)*sizeof(char*));
          B=(char**) malloc((MaxStringNumber+1)*sizeof(char*));
          C=(char**) malloc((MaxStringNumber+1)*sizeof(char*));
  
          printf("Array A:\n");
          reading(A,MaxStringNumber);
          Count(A,B,MaxStringNumber);
          printf("Sorted:\n");
          printing(B,MaxStringNumber);
  
          return 0;
  }
  </code></pre>