title: stringstream: Why isn't this code returning 4?
body: <pre><code>#include &lt;iostream&gt;
  #include &lt;sstream&gt;
  
  using namespace std;
  
  int get_4()
  {
    char c = '4';
    stringstream s(ios::in);
    s &lt;&lt; c;
    int i;
    s &gt;&gt; i;
    return i;
  }
  
  int main()
  {
    cout &lt;&lt; get_4() &lt;&lt; endl;
  }
  </code></pre>
  
  <p>The conversion is not working for me. If I write a character '4' or character array {'4','\0'} to stringstream and then read it out to int i, I don't get back the 4. What is wrong with the above code?</p>