I am trying to look into a text file and compare the single input by their hexadecimal digits. I am comparing two .txt documents, everything is the same but my computer keeps reading them as different. I checked the hex version of these documents and I realized that that was where the difference is notice. I decided to write a program that can compare the input for me since I have so many to go through. I know where the problem is coming from already. It's the 0D 0A. Some have them other just have one of them. So I'm checking the characters to setting variables to previous and current. My problem is I'm having trouble coverting the cin.get(char) to a hex degit. Please help in any way. hex(10) is a dummy, I was just playing arounf to see what to do

Heres what I have so far

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

int main()
   char filename[25];   
   char current;

   ifstream in1;	// input file stream
   ofstream out1;	// an output file stream
   char previous = hex(10);

Then I have teh file input output code which I know works, then

while (!in1.eof())	// while not end of input file
		  in1.get(current);	// read a character from input file
		 if (previous == hex(12) && current == hex(10))
			 out1 << "This is fine" << endl;
			 out1 << previous << endl;
		 if (previous == hex(12) && current != hex(10))
			 out1 << "Previous is 12 but Current is not 10" << endl;
			 out1 << previous << endl;
		 if (previous != hex(12) && current == hex(10))
			 out1 << "Previous is not 12 but Current is 10" << endl;
			 out1 << previous << endl;
			 previous = current;

Edited by ana_1234: n/a

7 Years
Discussion Span
Last Post by ana_1234
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.