I've used:
sprintf(hex, "%02x", (unsigned int) buffer[0] & 0xff);
to get hexadecimal representation of binary file. After that I save this representation to txt file.
Now I' d like to execute inverse operation. How can I create binary file from my hex data?