﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-Shuffy-最新评论</title><link>http://www.cppblog.com/Sandywin/CommentsRSS.aspx</link><description>&lt;body 
bgproperties="fixed";
background="http://www.cppblog.com/images/cppblog_com/Sandywin/4194/o_the,dreamy,world,115828072343234.jpg" wight=1024 height=768&gt;
&lt;b&gt;不断的学习，不断的思考，才能不断的进步.Let's do better together!&lt;/b&gt;</description><language>zh-cn</language><pubDate>Sat, 12 Sep 2015 02:46:57 GMT</pubDate><lastBuildDate>Sat, 12 Sep 2015 02:46:57 GMT</lastBuildDate><generator>cnblogs</generator><item><title>re: stringstream的用法 </title><link>http://www.cppblog.com/Sandywin/archive/2015/07/18/27984.html#211293</link><dc:creator>czbreborn</dc:creator><author>czbreborn</author><pubDate>Sat, 18 Jul 2015 03:47:00 GMT</pubDate><guid>http://www.cppblog.com/Sandywin/archive/2015/07/18/27984.html#211293</guid><description><![CDATA[#include &lt;sstream&gt;<br>#include &lt;iostream&gt;<br>int main()<br>{<br>    std::stringstream stream;<br>    int first, second;<br>    stream&lt;&lt; &quot;456&quot;; //插入字符串<br>    stream &gt;&gt; first; //转换成int<br>    /*这个时候stream已经是eofbit状态了 所以接下来需要进行clear才能继续往stream写入数据*/<br>    std::cout &lt;&lt; first &lt;&lt; std::endl;<br>    stream.clear(); //在进行多次转换前，必须清除stream<br>    stream &lt;&lt; true; //插入bool值<br>    stream &gt;&gt; second; //提取出int<br>    std::cout &lt;&lt; second &lt;&lt; std::endl;<br>} <br><br>如果stream中的字符串没有全部读取完，可以用str(&quot;&quot;)来清空，所以根据不同的情况使用clear和str。<img src ="http://www.cppblog.com/Sandywin/aggbug/211293.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Sandywin/" target="_blank">czbreborn</a> 2015-07-18 11:47 <a href="http://www.cppblog.com/Sandywin/archive/2015/07/18/27984.html#211293#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>re: stringstream的用法 </title><link>http://www.cppblog.com/Sandywin/archive/2014/11/08/27984.html#208820</link><dc:creator>wapeter</dc:creator><author>wapeter</author><pubDate>Sat, 08 Nov 2014 14:43:00 GMT</pubDate><guid>http://www.cppblog.com/Sandywin/archive/2014/11/08/27984.html#208820</guid><description><![CDATA[2014-04-08 16:44 by wenpeng  这是正解<br><br>贴上测试过完整代码：<br><br>int test_sstream(int bug)<br>{<br>    stringstream stream;<br><br>    stream&lt;&lt;&quot;abc&quot;;<br>    int n;<br>    stream&gt;&gt;n;//这里的n将保持未初始化时的随机值<br><br><br>    if (bug &lt; 2) {<br>        stream.clear();//清除错误标志<br>    }<br>    if (bug &lt; 1) {<br>        stream.str(&quot;&quot;);//清除内容“abc”<br>    }<br>    //缺少上面两句中的任何一句都无法使得后面的s==“def”<br>    //相反，s将等于 “” 或 “abcedf”<br><br>    stream &lt;&lt; &quot;def&quot;;<br>    string s;<br>    stream&gt;&gt;s;<br>    cout &lt;&lt; &quot;BUG=&quot; &lt;&lt; bug &lt;&lt; &quot;  DEF = &quot; &lt;&lt; s &lt;&lt;endl;<br><br>    return 0;<br>}<br><br>int main()<br>{<br>    test_sstream(0);<br>    test_sstream(1);<br>    test_sstream(2);<br><br>   return 0<br>}<img src ="http://www.cppblog.com/Sandywin/aggbug/208820.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Sandywin/" target="_blank">wapeter</a> 2014-11-08 22:43 <a href="http://www.cppblog.com/Sandywin/archive/2014/11/08/27984.html#208820#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>re: stringstream的用法 </title><link>http://www.cppblog.com/Sandywin/archive/2014/07/26/27984.html#207816</link><dc:creator>兔兔的天空之城</dc:creator><author>兔兔的天空之城</author><pubDate>Sat, 26 Jul 2014 12:30:00 GMT</pubDate><guid>http://www.cppblog.com/Sandywin/archive/2014/07/26/27984.html#207816</guid><description><![CDATA[大神 好腻害！！！！！1<img src ="http://www.cppblog.com/Sandywin/aggbug/207816.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Sandywin/" target="_blank">兔兔的天空之城</a> 2014-07-26 20:30 <a href="http://www.cppblog.com/Sandywin/archive/2014/07/26/27984.html#207816#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>re: stringstream的用法 </title><link>http://www.cppblog.com/Sandywin/archive/2014/07/15/27984.html#207652</link><dc:creator>逸云</dc:creator><author>逸云</author><pubDate>Tue, 15 Jul 2014 07:52:00 GMT</pubDate><guid>http://www.cppblog.com/Sandywin/archive/2014/07/15/27984.html#207652</guid><description><![CDATA[间隔6年的讨论- -<img src ="http://www.cppblog.com/Sandywin/aggbug/207652.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Sandywin/" target="_blank">逸云</a> 2014-07-15 15:52 <a href="http://www.cppblog.com/Sandywin/archive/2014/07/15/27984.html#207652#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>re: stringstream的用法 [未登录]</title><link>http://www.cppblog.com/Sandywin/archive/2014/04/11/27984.html#206531</link><dc:creator>cc</dc:creator><author>cc</author><pubDate>Thu, 10 Apr 2014 17:15:00 GMT</pubDate><guid>http://www.cppblog.com/Sandywin/archive/2014/04/11/27984.html#206531</guid><description><![CDATA[正确方法<br>stream.str(&quot; &quot;);<br>stream&gt;clear();<img src ="http://www.cppblog.com/Sandywin/aggbug/206531.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Sandywin/" target="_blank">cc</a> 2014-04-11 01:15 <a href="http://www.cppblog.com/Sandywin/archive/2014/04/11/27984.html#206531#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>re: stringstream的用法 </title><link>http://www.cppblog.com/Sandywin/archive/2014/04/08/27984.html#206505</link><dc:creator>wenpeng</dc:creator><author>wenpeng</author><pubDate>Tue, 08 Apr 2014 08:44:00 GMT</pubDate><guid>http://www.cppblog.com/Sandywin/archive/2014/04/08/27984.html#206505</guid><description><![CDATA[stream&lt;&lt;&quot;abc&quot;;<br>int n;<br>stream&gt;&gt;n;//这里的n将保持未初始化时的随机值<br><br>stream.clear();//清除错误标志<br>stream.str(&quot;&quot;);//清除内容“abc”<br>//缺少上面两句中的任何一句都无法使得后面的s==“def”<br>//相反，s将等于 “” 或 “abcedf”<br><br>stream&lt;&lt;&quot;def&quot;;<br>string s;<br>stream&gt;&gt;s;<img src ="http://www.cppblog.com/Sandywin/aggbug/206505.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Sandywin/" target="_blank">wenpeng</a> 2014-04-08 16:44 <a href="http://www.cppblog.com/Sandywin/archive/2014/04/08/27984.html#206505#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>re: stringstream的用法 </title><link>http://www.cppblog.com/Sandywin/archive/2014/04/08/27984.html#206504</link><dc:creator>wenpeng</dc:creator><author>wenpeng</author><pubDate>Tue, 08 Apr 2014 08:39:00 GMT</pubDate><guid>http://www.cppblog.com/Sandywin/archive/2014/04/08/27984.html#206504</guid><description><![CDATA[正确的做法应该是clear和str(&quot;&quot;)都使用！<img src ="http://www.cppblog.com/Sandywin/aggbug/206504.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Sandywin/" target="_blank">wenpeng</a> 2014-04-08 16:39 <a href="http://www.cppblog.com/Sandywin/archive/2014/04/08/27984.html#206504#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>re: stringstream的用法 </title><link>http://www.cppblog.com/Sandywin/archive/2013/12/13/27984.html#204767</link><dc:creator>cangrui</dc:creator><author>cangrui</author><pubDate>Fri, 13 Dec 2013 03:38:00 GMT</pubDate><guid>http://www.cppblog.com/Sandywin/archive/2013/12/13/27984.html#204767</guid><description><![CDATA[str(&quot;&quot;)才是正解， clear是ios类继承过来，用于清错误标志的<img src ="http://www.cppblog.com/Sandywin/aggbug/204767.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Sandywin/" target="_blank">cangrui</a> 2013-12-13 11:38 <a href="http://www.cppblog.com/Sandywin/archive/2013/12/13/27984.html#204767#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>re: stringstream的用法 </title><link>http://www.cppblog.com/Sandywin/archive/2013/11/06/27984.html#204118</link><dc:creator>岁月漫步</dc:creator><author>岁月漫步</author><pubDate>Wed, 06 Nov 2013 02:27:00 GMT</pubDate><guid>http://www.cppblog.com/Sandywin/archive/2013/11/06/27984.html#204118</guid><description><![CDATA[stringstream可以减少我们很多工作量啊<img src ="http://www.cppblog.com/Sandywin/aggbug/204118.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Sandywin/" target="_blank">岁月漫步</a> 2013-11-06 10:27 <a href="http://www.cppblog.com/Sandywin/archive/2013/11/06/27984.html#204118#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>re: stringstream的用法 </title><link>http://www.cppblog.com/Sandywin/archive/2013/10/21/27984.html#203849</link><dc:creator>王恩培</dc:creator><author>王恩培</author><pubDate>Mon, 21 Oct 2013 05:48:00 GMT</pubDate><guid>http://www.cppblog.com/Sandywin/archive/2013/10/21/27984.html#203849</guid><description><![CDATA[请问这个如果转换失败<br>比如我要从int转bool失败的话 是怎么标记的呢？<img src ="http://www.cppblog.com/Sandywin/aggbug/203849.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Sandywin/" target="_blank">王恩培</a> 2013-10-21 13:48 <a href="http://www.cppblog.com/Sandywin/archive/2013/10/21/27984.html#203849#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>re: stringstream的用法 </title><link>http://www.cppblog.com/Sandywin/archive/2013/09/26/27984.html#203436</link><dc:creator>taniey</dc:creator><author>taniey</author><pubDate>Wed, 25 Sep 2013 16:18:00 GMT</pubDate><guid>http://www.cppblog.com/Sandywin/archive/2013/09/26/27984.html#203436</guid><description><![CDATA[hex 会影响后续的操作，所以输出的是十六进制中的0x12<img src ="http://www.cppblog.com/Sandywin/aggbug/203436.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Sandywin/" target="_blank">taniey</a> 2013-09-26 00:18 <a href="http://www.cppblog.com/Sandywin/archive/2013/09/26/27984.html#203436#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>re: stringstream的用法 </title><link>http://www.cppblog.com/Sandywin/archive/2013/02/03/27984.html#197695</link><dc:creator>ygqwan</dc:creator><author>ygqwan</author><pubDate>Sun, 03 Feb 2013 15:31:00 GMT</pubDate><guid>http://www.cppblog.com/Sandywin/archive/2013/02/03/27984.html#197695</guid><description><![CDATA[开始还以为楼主的str（“”）中不应该加引号呢，才发现需要加上才行@XiaoRenWu<br><img src ="http://www.cppblog.com/Sandywin/aggbug/197695.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Sandywin/" target="_blank">ygqwan</a> 2013-02-03 23:31 <a href="http://www.cppblog.com/Sandywin/archive/2013/02/03/27984.html#197695#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>re: stringstream的用法 </title><link>http://www.cppblog.com/Sandywin/archive/2013/02/03/27984.html#197694</link><dc:creator>ygqwan</dc:creator><author>ygqwan</author><pubDate>Sun, 03 Feb 2013 15:27:00 GMT</pubDate><guid>http://www.cppblog.com/Sandywin/archive/2013/02/03/27984.html#197694</guid><description><![CDATA[我觉得你能用时因为你一次性把stream中的字符全读出来了，如果字符是带有小数的，而用int读出，那么即使chear（）后也会影响后面的操作@XiaoRenWu<br><img src ="http://www.cppblog.com/Sandywin/aggbug/197694.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Sandywin/" target="_blank">ygqwan</a> 2013-02-03 23:27 <a href="http://www.cppblog.com/Sandywin/archive/2013/02/03/27984.html#197694#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>re: stringstream的用法 </title><link>http://www.cppblog.com/Sandywin/archive/2013/02/03/27984.html#197693</link><dc:creator>ygqwan</dc:creator><author>ygqwan</author><pubDate>Sun, 03 Feb 2013 15:22:00 GMT</pubDate><guid>http://www.cppblog.com/Sandywin/archive/2013/02/03/27984.html#197693</guid><description><![CDATA[楼主如果把例子3中stream中插入”3456.554“，后面会发现会发现stream中仍然还有字符串.554,我觉得在clear（）前面加上一句 char * temp;stream&gt;&gt;temp;比较好，这样stream流中就是空的了<img src ="http://www.cppblog.com/Sandywin/aggbug/197693.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Sandywin/" target="_blank">ygqwan</a> 2013-02-03 23:22 <a href="http://www.cppblog.com/Sandywin/archive/2013/02/03/27984.html#197693#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>re: stringstream的用法 </title><link>http://www.cppblog.com/Sandywin/archive/2012/10/05/27984.html#192887</link><dc:creator>呵呵</dc:creator><author>呵呵</author><pubDate>Fri, 05 Oct 2012 12:55:00 GMT</pubDate><guid>http://www.cppblog.com/Sandywin/archive/2012/10/05/27984.html#192887</guid><description><![CDATA[大神，俺粘贴到我的博客了。。留着看。。非常感谢。。    <img src ="http://www.cppblog.com/Sandywin/aggbug/192887.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Sandywin/" target="_blank">呵呵</a> 2012-10-05 20:55 <a href="http://www.cppblog.com/Sandywin/archive/2012/10/05/27984.html#192887#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>