title: Sorting array of strings in cpp using std:sort
body: <p>I am trying to sort arrays (yes, not vectors) of strings, following some suggestions from sites such as <a href="https://stackoverflow.com/questions/28213100/using-stdsort-to-sort-an-array-of-c-strings">this</a> one. This is the code I wrote so far, but it always prints out <a href="https://pastebin.com/pFqeXTLX" rel="nofollow noreferrer">this</a> long error (which has no results on google). How can this be fixed?</p>
  <pre><code>#include &lt;algorithm&gt;
  #include &lt;cstring&gt;
  #include &lt;iostream&gt;
  //qsort(names, n, 15, (int (*)(const void *, const void *))strcmp);
  
  
  
  int main()
  {
      std::cout &lt;&lt; &quot;hi&quot;;
      char arr[3][6];
      strcpy(arr[0], &quot;hello&quot;), strcpy(arr[1], &quot;hillo&quot;), strcpy(arr[2], &quot;hallo&quot;);
      std::sort(arr, arr + 3, [](char const *lhs,
                             char const *rhs) { return strcmp(lhs, rhs) &lt; 0; });
      //qsort(arr, 3, 20, (int (*)(const void *, const void *))strcmp);
      for (int i = 0; i &lt; 3; ++i)
          std::cout &lt;&lt; arr[i] &lt;&lt; '\n';
  }
  </code></pre>