How to import a binary file

Hi All,

I am working on a project where i need to import a binary file into a RichEdit. I searched all over and i could not find any help about this.

When i import the binary file, the most bytes are gone, it shows only the bytes that appeared to be ANSI code. so byte 0-32 are erased by RichEdit(i think)

I tried to put plaintext on, but that wont fix the problem.

Is there any way to import a complete binary file into RichEdit. It would be nice if the characters where shown as hex in stead of text.

The code i am using:

Kind Regards,



  • here is the answer to my own question.just in case someone is looking for it:


    int main () {
    char * buffer;
    long size;
    ifstream file ("example.dat", ios::in|ios::binary|ios::ate);
    size = file.tellg();
    file.seekg (0, ios::beg);
    buffer = new char [size]; (buffer, size);

    cout << "the complete file is in a buffer";

    delete[] buffer;
    return 0;


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion