I’m at the time beginning the development of a simple hex editor(that only reads at the time). I want to substitute OA for "\n", I’m trying with this code:
#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;
}
It compiles without errors, but when I try to execute it, I just got nothing:
C:\Documents and Settings\Nathan Campos\Desktop>hex
=====================================
C:\Documents and Settings\Nathan Campos\Desktop>
This is happening just after I’ve added the feature to substitute OA for \n, because before it was working very nice. What is wrong?
You realize that you are only reading a character once, and before even opening the file, at that?