title: Pig Latin converter c++ function
body: <p>I am in the process of developing a program that converts someones name into pig latin, my code is compiling and is very close to working however I have been given the <code>main()</code> and it cannot be edited. Below is my code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  
  
  using namespace std;
  
      void convertToPigLatin(string&amp; name);
      void lowercase(string&amp; name);
  
      int main()
      {
  
              string first = "Trevor";
              string last = "Chappel";
              string fullname;
              convertToPigLatin(first);
              convertToPigLatin(last);
              fullname = first + " " + last;
              cout &lt;&lt; "Your name in pig latin is: " &lt;&lt; fullname &lt;&lt; endl;
  
      }
  
      void convertToPigLatin(string &amp; name)
      {
          // begins with vowel.
          if (name[0] == 'a' || name[0] == 'e' || name[0] == 'i' || name[0] == 'o' || 
          name[0] == 'u' || name[0] == 'A' || name[0] == 'E' || name[0] == 'I' || name[0] == 'O' || name[0] == 'U')
          {
              // Add "way" to the end.
              name[0] = toupper(name[0]);
              cout &lt;&lt; name &lt;&lt; "way ";
          }
  
          // It begins with a consonant. Move it to the end and add "ay"
          else
          {
              name[0] = tolower(name[0]);
              name += name[0];
              name.erase(0, 1);
              name[0] = toupper(name[0]);
  
              cout &lt;&lt; name &lt;&lt; "ay ";
          }
      }
  
      void lowercase(string&amp; name)
      {
          int i = 1;
          while (name[i] != '\0')
          {
              name[i] = tolower(name[i]);
              i++;
          }
      }
  </code></pre>
  
  <p>My output is <code>Revortay Happelcay Your name in pig latin is: Trevor Chappel</code>
  and the desired output is <code>Your name in pig latin is: Evortray Appelchay</code>.
  So as you can see it is close. I have spent 4 hours on this and am not getting anywhere.</p>