title: Why does my bubble sort not work in C
body: <p>I am new on this site and self-learning how to program in C. The following code compiles without warning or error and executes, but the second print run is exactly the same as the first, i.e. my bubble sort routine does not work. A similar version of this using just single letter characters worked just fine. Any pointers (ahem...) would be appreciated as to where I am going wrong - thanks!</p>
  
  <p>The code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  int main()
  
  {
  
      char * names[10] = {"Dave","Al","Roger","Gary","Marc","Tim","Bob","Cal","Sid","Joe"};
  
      int beginning;
      int end;
      int didSwap;
      char * temp = "This will be used to store names temporarily";
      int ctr;
  
      puts("\nHere are some random names:");
      for (ctr = 0; ctr &lt; 10; ctr++)
      {   
          printf("%s\n", names[ctr]);
      }
  
      for (beginning = 0; beginning &lt; 9; beginning++)
      {
          didSwap = 0;
          for (end = beginning; end &lt; 10; end++)
          {
              if (names[end] &lt; names[beginning])
              {
                  temp = names[end];
                  names[end] = names[beginning];
                  names[beginning] = temp;
                  didSwap = 1;
              }
          }
          if (didSwap == 0)
              {
                  break;
              }
      }
  
      puts("\nHere are the random names now in alphabetical order:");
      for (ctr = 0; ctr &lt; 10; ctr++)
      {   
          printf("%s\n", names[ctr]);
      }
  
      return(0);
  }
  </code></pre>