Print file in binary mode
I'm trying to write a program that would read any file (in binary mode) and print, or write as a text file, the bits of the program.
Is there a function in STD that would do something like that?
My program doesn't do much at this point. It just reads a file in binary mode and stores the data as a char*.
I guess what I need right now is the fastest way to convert that char pointer into binary digits. The digits will probably be in a char array - by groups of 8.
Code:
ifstream::pos_type size;
char* mem;
int main ()
{
ifstream file("test.dll", ios::in|ios::binary|ios::ate);
size = file.tellg();
mem = new char[size];
file.seekg (0, ios::beg);
file.read (mem, size);
file.close();
delete[] mem;
return 0;
}
So how would I reliably and quickly convert all those chars to binary digits.
The plan is to open any file, store its 'binary digits' in a text file and be able to later open that text file and convert those binary digits into the same file.