title: Split comma separated string
body: <p>Brand new to c++ and im having difficulty splitting on a string. I have seen some examples of this on stack overflow, but I could not get the samples to work when looping in the for loop.</p>
  
  <p>Essentially I have an array of strings that looks like. </p>
  
  <pre><code>    const string userData[] =
     {"A1,John,Smith,smithJ@mail.com,42",
     "B2,Jane,Doe,jd@gmailcom,121,2",
     "C3,Mickey,Mouse,mouseman@mail.com,20"
     };   
  </code></pre>
  
  <p>Below is the closest I have gotten to a solution myself</p>
  
  <pre><code> string s;
   vector&lt;istringstream&gt; streamV;
   vector&lt;string&gt; stringV;
   for(const auto&amp; str : userData)
   {
        istringstream nasa { str };
        getline(nasa, s, ',');
        stringV.push_back(s);
  
   }
   cout &lt;&lt; stringV[0] &lt;&lt; endl;
   cout &lt;&lt; stringV[1] &lt;&lt; endl;
  </code></pre>
  
  <p>Output</p>
  
  <pre><code>A1
  B1
  </code></pre>
  
  <p>Desired goal:
  I want to have each comma separated value added to a vector.
  Then, call out class constructors doing some inline typecasting for the last value from a string to an int.</p>
  
  <p>Edit1 
  I understand my question is similar to <a href="https://stackoverflow.com/questions/236129/the-most-elegant-way-to-iterate-the-words-of-a-string">The most elegant way to iterate the words of a string</a>
  The main difference was that the solutions provided did not work well with a comma separated list, and as well iterating through an array/vector.</p>