title: Sorting an array of strings with Bubble sort
body: <p>Any help would be greatly appreciated.
  I am trying to sort 12 strings alphabetically which are contained in an array using bubble sort with the following code: </p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  int main()
  {
     //initialising variables and the array
     char *DT [12] = { "James Smith DT01 DT265A", "John Murphy DT02 DT265A", "Robert Lam DT03 DT265A", "Michael Martin DT04 DT265A", "William Brown DT05 DT265A", "David Roy DT06 DT265A", "Richard Tremblay DT07 DT265A", "Joseph Lee DT08 DT265A", "Thomas Gagnon DT09 DT265A", "Charles Wilson DT10 DT265A", "Chris Philips DT11 DT265A", "Henry Hill DT12 DT265A"  } ;
     char temp[100];
     int n = sizeof(DT)/sizeof(DT[0]);
  
     //Implementing Algorithm using bubble sort to sort string array
     //
     for (int j = 0 ; j &lt; n - 1 ; j++ )
     {
        for (int i = j + 1 ; i &lt; n ; i++ )
        {
           if( strcmp(DT[j], DT[i]) &gt; 0 ) 
           {
              strcpy(temp, DT[j]);
              strcpy(DT[j], DT[i]);
              strcpy(DT[i], temp);
           }//end if
        }//end for
     }//end for
     printf("Strings in sorted order are : ");
     for (int i=0; i&lt;n; i++)
     {
        printf("\n String %d is %s", i+1, DT[i]);
     }
  
     getchar();
     getchar();
     return 0;
  }//end main()
  </code></pre>
  
  <p>The output I get is: </p>
  
  <p>Strings in sorted order are :</p>
  
  <p>String 1 is A</p>
  
  <p>String 2 is A</p>
  
  <p>String 3 is 2vid Roy DT06 DT265A</p>
  
  <p>String 4 is  Roy DT06 DT265A</p>
  
  <p>String 5 is Charles Wilson DT10 DT265A</p>
  
  <p>String 6 is</p>
  
  <p>String 7 is Chris Philips DT11 DT265A</p>
  
  <p>String 8 is 06 DT265A</p>
  
  <p>String 9 is avidRoy DT06 DT265A</p>
  
  <p>String 10 is mith DT01 DT265David Roy Dyy DT06 DT265A</p>
  
  <p>String 11 is y DT06 DT265A</p>
  
  <p>String 12 is y DT06 DT265A</p>