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

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

  • <tfoot id='Qs0Ll'></tfoot>

          <bdo id='Qs0Ll'></bdo><ul id='Qs0Ll'></ul>

        C++ cin char 逐个符号读取

        时间:2024-08-13

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

          <tfoot id='HwSYH'></tfoot>

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

                  本文介绍了C++ cin char 逐个符号读取的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我需要逐个符号阅读.但我不知道如何阅读,直到输入结束.例如,测试系统将 cin>>somecharvariable m 次.我必须逐个符号阅读所有字符.只有m次.我该怎么做?

                  I need to read symbol-by-symbol. But I don't know how to read until end of input. As exemple test system will cin>>somecharvariable m times. I have to read symbol-by-symbol all characters. Only m times. How I can do it?

                  推荐答案

                  如果您想逐个字符地格式化输入,请执行以下操作:

                  If you want formatted input character-by-character, do this:

                  char c;
                  while (infile >> c)
                  {
                    // process character c
                  }
                  

                  如果您想读取原始字节,请执行以下操作:

                  If you want to read raw bytes, do this:

                  char b;
                  while (infile.get(b))
                  // while(infile.read(&b, 1)   // alternative, compare and profile
                  {
                    // process byte b
                  }
                  

                  在任何一种情况下,infile 都应该是 std::istream & 或类似的类型,例如文件或 std::cin>.

                  In either case, infile should be of type std::istream & or similar, such as a file or std::cin.

                  这篇关于C++ cin char 逐个符号读取的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:cout uint8_t 作为整数而不是字符 下一篇:如何确定输出流链是否结束?

                  相关文章

                    <tfoot id='g1DYy'></tfoot>

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

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

                      • <bdo id='g1DYy'></bdo><ul id='g1DYy'></ul>