<legend id='Nzqi5'><style id='Nzqi5'><dir id='Nzqi5'><q id='Nzqi5'></q></dir></style></legend>

    <tfoot id='Nzqi5'></tfoot>

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

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

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

        如何在 C++ 中逐个字符地从文本文件中读取

        时间:2023-07-01
      2. <tfoot id='l3Tfr'></tfoot>

        1. <legend id='l3Tfr'><style id='l3Tfr'><dir id='l3Tfr'><q id='l3Tfr'></q></dir></style></legend>
              <tbody id='l3Tfr'></tbody>

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

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

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

                  问题描述

                  我想知道是否有人可以帮助我弄清楚如何从 C++ 中的文本文件中逐个字符地读取.这样,我可以有一个 while 循环(虽然仍有文本),我将文本文档中的下一个字符存储在临时变量中,以便我可以对它做一些事情,然后对下一个字符重复该过程.我知道如何打开文件和所有内容,但 temp = textFile.getchar() 似乎不起作用.提前致谢.

                  I was wondering if someone could help me figure out how to read from a text file in C++, character by character. That way, I could have a while loop (while there's still text left) where I store the next character in the text document in a temp variable so I could do something with it, then repeat the process with the next character. I know how to open the file and everything, but temp = textFile.getchar() doesn't seem to work. Thanks in advance.

                  推荐答案

                  您可以尝试以下操作:

                  char ch;
                  fstream fin("file", fstream::in);
                  while (fin >> noskipws >> ch) {
                      cout << ch; // Or whatever
                  }
                  

                  这篇关于如何在 C++ 中逐个字符地从文本文件中读取的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:使用 C++ 读取文本文件的最优雅方式是什么? 下一篇:如何更改 Windows 控制台应用程序中的文本或背景颜色

                  相关文章

                  <tfoot id='n0mK4'></tfoot>
                  • <bdo id='n0mK4'></bdo><ul id='n0mK4'></ul>

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

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