title: How to obtain a floating point value from a string?
body: <p>I am using <code>istringstream</code> from <code>&lt;sstream&gt;</code> header library to process the string, which works well for <em>integer</em> values but not for <em>floats</em>. The output I get are all integers for the below code.</p>
  
  <pre class="lang-cpp prettyprint-override"><code>#include &lt;iostream&gt;
  #include &lt;sstream&gt;
  #include &lt;string&gt;
  
  using std::istringstream;
  using std::string;
  using std::cout;
  
  int main () 
  {
      string a("1 2.0 3");
  
      istringstream my_stream(a);
  
      int n;
      float m, o;
      my_stream &gt;&gt; n &gt;&gt; m &gt;&gt; o;
      cout &lt;&lt; n &lt;&lt; "\n";
      cout &lt;&lt; m &lt;&lt; "\n";
      cout &lt;&lt; o &lt;&lt; "\n";
  }
  </code></pre>
  
  <p>I want output of <code>m</code> to be <code>2.0</code>, but I am getting it as just integer <code>2</code>. Am I missing something here, or should I be using a something else?</p>