title: Retrieving the first char of a string and comparing it alphabetically in C++
body: <p>I'm a novice programmer learning C++ through a tutorial and I want to know how I can take a string, take its first letter, compare it to the first letters of 2 other strings and then sort them alphabetically.  I don't want code written for me.  I want to understand how to do this because other solutions were difficult to understand.</p>
  
  <p>I know that strings are just arrays of char so there should be a method to get the first index.  </p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>So this is my attempt:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  using namespace std;
  
  void valueOutput(string firstName, string secondName, string thirdName){
      cout &lt;&lt; "\n";
      cout &lt;&lt; firstName &lt;&lt; endl;
      cout &lt;&lt; secondName &lt;&lt; endl;
      cout &lt;&lt; thirdName &lt;&lt; endl;
  }
  
  int main(){
      string name1, name2, name3;
  
      cout&lt;&lt;"Enter 3 names: "&lt;&lt;endl;
  
      cin&gt;&gt;name1;
      cin&gt;&gt;name2;
      cin&gt;&gt;name3;
  
      if(
         (name1[0] &lt; name2[0] &amp;&amp; name2[0] &lt; name3[0]) 
      || (name1[0] &lt; name3[0] &amp;&amp; name3[0] &lt; name2[0])
      || (name2[0] &lt; name1[0] &amp;&amp; name1[0] &lt; name3[0])
      || (name2[0] &lt; name3[0] &amp;&amp; name3[0] &lt; name1[0])
      || (name3[0] &lt; name1[0] &amp;&amp; name1[0] &lt; name2[0]) 
      || (name3[0] &lt; name2[0] &amp;&amp; name2[0] &lt; name1[0]))
      {valueOutput(name1, name2, name3);}
      else{
          return 0;
      }
  
  }
  </code></pre>
  
  <p>My input was:
  Steinbeck
  Hemingway
  Fitzgerald  </p>
  
  <p>but the output is the exactly in the same order.  I want to sort them alphabetically.</p>