我当时正在开始开发一个简单的十六进制编辑器(当时只能读取).我想替换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,因为在此之前,它正在非常好.怎么了?
| 归档时间: |
|
| 查看次数: |
232 次 |
| 最近记录: |