How to import a binary file - Programmers Heaven

Howdy, Stranger!

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


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

How to import a binary file

MidasTheDudeMidasTheDude Posts: 2Member
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,



  • MidasTheDudeMidasTheDude Posts: 2Member
    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.