<bdo id='OyTi0'></bdo><ul id='OyTi0'></ul>
  1. <tfoot id='OyTi0'></tfoot>
  2. <small id='OyTi0'></small><noframes id='OyTi0'>

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

      如何表示循环中不再有字符串 ss 的输入 while (cin &gt;&gt; ss)

      How to signify no more input for string ss in the loop while (cin gt;gt; ss)(如何表示循环中不再有字符串 ss 的输入 while (cin gt;gt; ss))
          <bdo id='gFnSx'></bdo><ul id='gFnSx'></ul>
          <legend id='gFnSx'><style id='gFnSx'><dir id='gFnSx'><q id='gFnSx'></q></dir></style></legend>

          <tfoot id='gFnSx'></tfoot>

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

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

                  <tbody id='gFnSx'></tbody>
              1. 本文介绍了如何表示循环中不再有字符串 ss 的输入 while (cin &gt;&gt; ss)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我使用cin"从输入流中读取单词,例如

                I used "cin" to read words from input stream, which like

                int main( ){
                     string word;
                     while (cin >> word){
                         //do sth on the input word
                     }
                
                    // perform some other operations
                }
                

                代码结构与上面类似.它是可编译的.在执行过程中,我不断输入类似

                The code structure is something like the above one. It is compilable. During the execution, I keep inputting something like

                aa bb cc dd
                

                我的问题是如何结束这个输入?换句话说,假设文本文件只是aa bb cc dd".但是我不知道如何让程序知道文件结束了.

                My question is how to end this input? In other words, suppose the textfile is just "aa bb cc dd". But I do not know how to let the program know that the file ends.

                推荐答案

                您的代码是正确的.如果是交互式输入,则需要发送 EOF 字符,例如 CTRL-D.

                Your code is correct. If you were interactively inputting, you would need to send a EOF character, such as CTRL-D.

                读取文件时不需要此 EOF 字符.这是因为一旦到达输入流的末尾,cin"就没有任何剩余(因为流现在已关闭),因此 while 循环退出.

                This EOF character isn't needed when you are reading in a file. This is because once you hit the end of your input stream, there is nothing left to "cin"(because the stream is now closed), thus the while loop exits.

                这篇关于如何表示循环中不再有字符串 ss 的输入 while (cin &gt;&gt; ss)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                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?)
                  <tbody id='b6uAs'></tbody>

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

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

                      <tfoot id='b6uAs'></tfoot>
                      • <bdo id='b6uAs'></bdo><ul id='b6uAs'></ul>
                        <legend id='b6uAs'><style id='b6uAs'><dir id='b6uAs'><q id='b6uAs'></q></dir></style></legend>