Simple C++ code (what's wrong here?)
<p>Noob to C++.</p>

<p>I'm trying to get user input (Last Name, First Name Middle Name), change part of it (Middle Name to Middle Initial) and then rearrange it (First Middle Initial Last).</p>

<p>Where am I messing up in my code?  </p>

<p>--Thanks for ANY help you can offer!</p>

<p>...</p>

<pre><code>#include &lt;iostream&gt;
using std::cout;
using std::cin;

#include &lt;string&gt;
using std::string;

int main()
{

  string myString, last, first, middle;

  cout &lt;&lt; "Enter your name: Last, First Middle";

  cin &gt;&gt; last &gt;&gt; first &gt;&gt; middle;

  char comma, space1, space2;

  comma = myString.find_first_of(',');
  space1 = myString.find_first_of(' ');
  space2 = myString.find_last_of(' ');

  last = myString.substr (0, comma); // user input last name
  first = myString.substr (space1+1, -1); // user input first name
  middle = myString.substr (space2+1, -1); // user input middle name

  middle.insert (0, space2+1); // inserts middle initial in front of middle name
  middle.erase (1, -1); // deletes full middle name, leaving only middle initial

  myString = first + ' ' + middle + ' ' + last; //  

  return 0;
}
</code></pre>
