用0A代替\n

Nat*_*pos 0 c++ file-io hex

我当时正在开始开发一个简单的十六进制编辑器(当时只能读取).我想替换OA"\n",我使用此代码尝试:

#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;

int main() {
   ifstream infile;
   int crtchar = (int)infile.get();
   infile.open("test.txt", ifstream::in);
   while(infile.good())
   {
      if(crtchar != 0xA)
         cout << hex << setfill('0') << setw(2) << crtchar << ":";
      else
         cout << endl;
   }
   cout << "\n=====================================\n";
   infile.close();
   return 0;
}
Run Code Online (Sandbox Code Playgroud)

它编译时没有错误,但是当我尝试执行它时,我什么也没得到:

C:\ Documents and Settings\Nathan Campos\Desktop> hex

=====================================

C:\ Documents and Settings\Nathan Campos\Desktop>

这是刚刚发生的经过我已经添加了功能替代OA\n,因为在此之前,它正在非常好.怎么了?

Kon*_*lph 7

你意识到你只是读一字符一次,和之前甚至打开文件,在那?