title: Splitting string to 2 vectors. Trouble converting string to float type
body: <p>Below I have a string called line that is coming from a file. The string has commas to separate it, where the first part goes to a string vector, and the second to a float vector. Anything after that is not used.</p>
  
  <p>The first part comes out as "text", which is correct. But the second one shows "248", while it's supposed to say "1.234"</p>
  
  <p>I need help converting this correctly. Any help would be greatly appreciated, thanks.</p>
  
  <p>I'm very new to programming. Sorry for any horrible style.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;vector&gt;
  using namespace std;
  
  int main ()
  {
    string line ("test,1.234,4.3245,5.231");
    string comma (",");
    size_t found;
    size_t found2;
    string round1;
    float round2;
    vector&lt;string&gt; vector1;
    vector&lt;float&gt; vector2;
  
    // Finds locations of first 2 commas
    found = line.find(comma);
    if (found!=string::npos)
  
    found2 = line.find(comma,found+1);
    if (found2!=string::npos)
  
  
  
  
  
      //Puts data before first comma to round1 (string type)
      for (int a = 0; a &lt; found; a++){
      round1 = round1 += line[a];
      }
  
      //Puts data after first comma and before second comma to round2 (float type)
      for (int b = found+1; b &lt; found2; b++){
      round2 = round2 += line[b];
      }
  
  
      //Puts data to vectors
      vector1.push_back(round1);
      vector2.push_back(round2);
  
  
  cout &lt;&lt; vector1[0] &lt;&lt; endl &lt;&lt; vector2[0] &lt;&lt; endl;
  
  
    return 0;
  }
  </code></pre>