title: type conversion in comparison function of stdlib qsort
body: <p>This code snippet is mainly from man page of qsort.</p>
  
  <pre><code>int cmp(const void *p1, const void *p2)
  {
     char s1 = *(*(char * const *)p1);
     char s2 = *(*(char * const *)p2);
     return s1 - s2;
  }
  
  int main(int argc, char *argv[])
  {
    int j; 
    printf("Before Qsort: \n");
    for(j = 1; j &lt;argc ; j++)
      printf("%s ", argv[j]);
    printf("\n");
    qsort(&amp;argv[1], argc - 1, sizeof(char *), cmp);
    printf("After Qsort: \n");
    for(j = 1; j &lt;argc ; j++)
      printf("%s ", argv[j]);
    printf("\n");
  }
  </code></pre>
  
  <p>I can understand I pass the address of pointer to char array which is &amp;argv[1] in the qsort
  However, I am confused why I have to do the following cast to get the value?</p>
  
  <p><code>*(*(char * const *)p1)</code></p>
  
  <p>I also checked other questions in stackoverflow, it is easy when we pass 1-D array.
  So, I can use </p>
  
  <p>type var = *(const type *)p1 to get the value</p>
  
  <p>Looking into this example, the type cast looks so weird to understand.</p>
  
  <p>Would you please help me to understand the meaning of every piece cast to reach the final value?</p>
  
  <p>Thanks.</p>