redirect cin to a string in c++
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/4925150/redirect-cin-to-a-string">Redirect cin to a string</a>  </p>
</blockquote>



<p>I saw <a href="http://stackoverflow.com/questions/1162068/redirect-both-cout-and-stdout-to-a-string-in-c-for-unit-testing">this post</a> on how to redirect <code>cout</code> to a string. But how to redirect the <code>cin</code> to a string, just like redirecting <code>cin</code> to a file using <code>freopen</code>, so that when I do <code>cin&gt;&gt;a_int;</code>, I will get an int from the string? Can I do similarly with <code>setbuf (stdin , buffer);</code></p>
