title: How to sort Struct using qsort in C programming
body: <p>I have created an array of struct and i would like to sort them using qsort to sort dates chronologically to the string month or i should say char month[]. how can i make the following code display the struct according to a month. please advice. thanks</p>
  
  <pre><code>struct dates
  {
      int index;
      int day;
      int year;
      char month[15];
  };
  
  
  int i=0;
  int count = 0 ;
  char test ='\0';
  int total =0;
  
  printf("Please enter the number of dates you need to display");
  scanf("%d",&amp;total);
  struct dates *ip[total];
  
  for(count =0; count&lt; total; count++){
      ip[count] = (struct dates*)malloc(sizeof(struct dates));
  
      printf("\nEnter the name month.");
      scanf("%s", ip[count]-&gt;month);
  
      printf("\nEnter the Day.");
      scanf("%d",&amp;ip[count]-&gt;day);
  
      printf("\nEnter the Year.");
      scanf("%d", &amp;ip[count]-&gt;year);                      
  }
  
  for(i=0; i&lt;total; i++){
      printf("%s %d %d\n\n",ip[i]-&gt;month,ip[i]-&gt;day,ip[i]-&gt;year);
  }
  </code></pre>