title: How to insertsort array of strings in C?
body: <p>How can I sort an array of strings with the insertion sort algorithm? I actually have 3 arrays of strings --> <code>a</code>,<code>b</code>,<code>c</code> and I want to sort all of them parallel <strong>based on array a</strong>. I've written the code which I think is correct, but gives an error:</p>
  
  <pre><code>int main() {
  
  /* the insertsort call is */ InsertSort (count, A, B, C);
  /* A, B, and C are arrays of strings */
  /* count is the size of the array */
  
  }
  
  void InsertSort (int n, char *a[17], char *b[17], char *c[5]){
  char *temp = malloc(17);
  char *temp1 = malloc(17);
  char *temp2 = malloc(5);
      int i, j;
      for (i=1; i&lt;n; i++) {
          j=i-1;
          while (j&gt;=0 &amp;&amp; strcmp(a[j],a[j+1])&lt;0) {
              strcpy(temp, a[j]);
              strcpy(a[j], a[j+1]);
              strcpy(a[j+1], temp);
  
              strcpy(temp1, b[j]);
              strcpy(b[j], b[j+1]);
              strcpy(b[j+1], temp1);
  
              strcpy(temp2, c[j]);
              strcpy(c[j], c[j+1]);
              strcpy(c[j+1], temp2);
              j--;
          }
      }
  }
  </code></pre>
  
  <p>Could you please help?</p>
  
  <p>Thanks a ton!</p>