1. <small id='LBptW'></small><noframes id='LBptW'>

        <bdo id='LBptW'></bdo><ul id='LBptW'></ul>
    2. <tfoot id='LBptW'></tfoot><legend id='LBptW'><style id='LBptW'><dir id='LBptW'><q id='LBptW'></q></dir></style></legend>

      <i id='LBptW'><tr id='LBptW'><dt id='LBptW'><q id='LBptW'><span id='LBptW'><b id='LBptW'><form id='LBptW'><ins id='LBptW'></ins><ul id='LBptW'></ul><sub id='LBptW'></sub></form><legend id='LBptW'></legend><bdo id='LBptW'><pre id='LBptW'><center id='LBptW'></center></pre></bdo></b><th id='LBptW'></th></span></q></dt></tr></i><div id='LBptW'><tfoot id='LBptW'></tfoot><dl id='LBptW'><fieldset id='LBptW'></fieldset></dl></div>

      1. C++ - 反复使用 istringstream

        C++ - repeatedly using istringstream(C++ - 反复使用 istringstream)
          <bdo id='xe9sN'></bdo><ul id='xe9sN'></ul>
            1. <i id='xe9sN'><tr id='xe9sN'><dt id='xe9sN'><q id='xe9sN'><span id='xe9sN'><b id='xe9sN'><form id='xe9sN'><ins id='xe9sN'></ins><ul id='xe9sN'></ul><sub id='xe9sN'></sub></form><legend id='xe9sN'></legend><bdo id='xe9sN'><pre id='xe9sN'><center id='xe9sN'></center></pre></bdo></b><th id='xe9sN'></th></span></q></dt></tr></i><div id='xe9sN'><tfoot id='xe9sN'></tfoot><dl id='xe9sN'><fieldset id='xe9sN'></fieldset></dl></div>

                  <tfoot id='xe9sN'></tfoot>

                  <small id='xe9sN'></small><noframes id='xe9sN'>

                1. <legend id='xe9sN'><style id='xe9sN'><dir id='xe9sN'><q id='xe9sN'></q></dir></style></legend>
                    <tbody id='xe9sN'></tbody>
                  本文介绍了C++ - 反复使用 istringstream的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个代码用于读取在线存储的带有浮点数的文件:3.34|2.3409|1.0001|...|1.1|".我想使用 istringstream 来读取它们,但它不像我期望的那样工作:

                  I have a code for reading files with float numbers on line stored like this: "3.34|2.3409|1.0001|...|1.1|". I would like to read them using istringstream, but it doesn't work as I would expect:

                    string row;
                    string strNum;
                  
                    istringstream separate;  // textovy stream pro konverzi
                  
                     while ( getline(file,row) ) {
                        separate.str(row);  // = HERE is PROBLEM =
                        while( getline(separate, strNum, '|') )  { // using delimiter
                          flNum = strToFl(strNum);    // my conversion
                          insertIntoMatrix(i,j,flNum);  // some function
                          j++;
                        }
                        i++;
                      }
                  

                  在标记点,仅第一次将行复制到单独的流中.在下一次迭代中,它不起作用并且什么也不做.我希望可以在每次迭代中不构建新的 istringstream 对象的情况下使用更多次.

                  In marked point, row is copied into separate stream only first time. In next iteration it doesn't work and it does nothing. I expected it is possible to be used more times without constructing new istringstream object in every iteration.

                  推荐答案

                  将行设置到 istringstream 后...

                  After setting the row into the istringstream...

                  separate.str(row);
                  

                  ...通过调用重置它

                  separate.clear();
                  

                  这会清除在前一次迭代中或通过设置字符串设置的任何 iostate 标志.http://www.cplusplus.com/reference/iostream/ios/clear/

                  This clears any iostate flags that are set in the previous iteration or by setting the string. http://www.cplusplus.com/reference/iostream/ios/clear/

                  这篇关于C++ - 反复使用 istringstream的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  What is inside .lib file of Static library, Statically linked dynamic library and dynamically linked dynamic library?(静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么?)
                  How do I load a C DLL from the SXS in Python?(如何从 Python 中的 SXS 加载 C DLL?)
                  Can Cython code be compiled to a dll so C++ application can call it?(Cython 代码可以编译成 dll 以便 C++ 应用程序可以调用它吗?)
                  Delay Loading DLLs(延迟加载 DLL)
                  Throwing C++ exceptions across DLL boundaries(跨 DLL 边界抛出 C++ 异常)
                  Loading a dll from a dll?(从 dll 加载 dll?)
                  1. <i id='R5TmG'><tr id='R5TmG'><dt id='R5TmG'><q id='R5TmG'><span id='R5TmG'><b id='R5TmG'><form id='R5TmG'><ins id='R5TmG'></ins><ul id='R5TmG'></ul><sub id='R5TmG'></sub></form><legend id='R5TmG'></legend><bdo id='R5TmG'><pre id='R5TmG'><center id='R5TmG'></center></pre></bdo></b><th id='R5TmG'></th></span></q></dt></tr></i><div id='R5TmG'><tfoot id='R5TmG'></tfoot><dl id='R5TmG'><fieldset id='R5TmG'></fieldset></dl></div>
                      <legend id='R5TmG'><style id='R5TmG'><dir id='R5TmG'><q id='R5TmG'></q></dir></style></legend>

                      <tfoot id='R5TmG'></tfoot>
                        <bdo id='R5TmG'></bdo><ul id='R5TmG'></ul>

                        • <small id='R5TmG'></small><noframes id='R5TmG'>

                            <tbody id='R5TmG'></tbody>