title: convert string to int use sstream
body: <p>We want to convert string to int using <strong>sstream</strong>.</p>
  
  <p>But we don't know our string has an integer or not, for example it can be the <strong><em>"hello 200"</em></strong> and we want <strong>200</strong> in that, or it can be <strong><em>"hello"</em></strong> and there was <strong>no solution</strong>!</p>
  
  <p>I have this code when we have only an integer in the string:</p>
  
  <pre><code>inline int string_to_int(string s)
  {
      stringstream ss(s);
      int x;
      ss &gt;&gt; x;
      return x;
  }
  </code></pre>
  
  <p>Now, if s = "hello 200!" or s = "hello" , how we can do that?</p>