<<sponging continued from here http://cboard.cprogramming.com/showthread.php?t=83717>>
Hello every one.... can you help me out here...
I need to make 2 programms.. on C and other same C++
I need to make a programms that read binary file (like txt file) and produce a hexadecimal dump of that file.
output should look like this (out put should be stored in new txt file)
http://img239.imageshack.us/img239/9...titled1ua6.jpg
Also command line should be used to get the name of data file. and then program will use a lookup table to convert the binary byte to a hex character. Using printf is disallowed.
Here is C++ exemples I am trying to get working..
In C++ I was able to open file.. and write some to it.. but.. how do I change it to hex?
Here what I did in C++
This programm just drive me nuts..... plz help.
That file enty part...Code:#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
{
string fileName;
ifstream inData;
ofstream outData;
cout << "Enter the input file name: ";
cin >> fileName;
inData.open(fileName.c_str());
outData.open("name1.txt");
}
Here is how I can write some thing using original file content.. and change it and write it to new file...
Code:string socialNum;
string firstName;
string lastName;
string middleName;
string initial;
inData >> socialNum >> firstName >> middleName >> lastName;
initial = middleName.substr(0, 1) + '.';
outData << firstName << ' ' << middleName << ' ' << lastName
<< ' ' << socialNum << endl;
outData << lastName << ", " << firstName << ' ' << middleName
<< ' ' << socialNum << endl;
outData << lastName << ", " << firstName << ' ' << initial
<< ' ' << socialNum << endl;
outData << firstName << ' ' << initial << ' ' << lastName;
inData.close();
outData.close();
return 0;
But now... How do I use hex table to get data file in to hex..
Code:}
unsigned char lower(unsigned char c)
{
unsigned char one_byte;
one_byte = c & 0x0F;
return one_byte;
}
unsigned char upper(unsigned char c)
{
unsigned char one_byte;
one_byte = (c & 0xF0) >> 4;
return one_byte;
}