title: How to alphabetically sort strings?
body: <p>I have been trying to use this c++ program to sort 5 names alphabetically:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;cstring&gt;
  #include &lt;conio.h&gt;
  using namespace std;
  
  int main()
  {
  char names[5][100];
  int x,y,z;
  
  char exchange[100];
  
  cout &lt;&lt; "Enter five names...\n";
  
  for(x=1;x&lt;=5;x++)
  {
      cout &lt;&lt; x &lt;&lt; ". ";
      cin &gt;&gt; names[x-1];
  }
  getch();
  
  for(x=0;x&lt;=5-2;x++)
  {
      for(y=0;y&lt;=5-2;y++)
      {
          for(z=0;z&lt;=99;z++)
          {
              if(int(names[y][z])&gt;int(names[y+1][z]))
              {   
                  strcpy(exchange,names[y]);
                  strcpy(names[y],names[y+1]);
                  strcpy(names[y+1],exchange);
                  break;
              }
          }   
      }
  }   
  
  for(x=0;x&lt;=5-1;x++)
      cout &lt;&lt; names[x];
  
  return 0;
  }
  </code></pre>
  
  <p>If I enter Earl, Don, Chris, Bill, and Andy respectively, I get this:</p>
  
  <pre><code>AndyEarlDonChrisBill
  </code></pre>
  
  <p>Could someone please tell me whats wrong with my program?</p>