'Is there a way to convert a .bin file to an ASCII file in C++?

I am new to C++ and wanted to know if a .bin file can be converted to an ASCII file (ASCII file is to be loaded onto EXCEL for further data analysis). The binary log file contains a bunch of messages (BinarayMessage1, BinarayMessage2...) in the form of structures. One such example is as follows:

 typedef struct
 {
   SHeader header; //8 bytes, SHeader is a structure defining the message header
   signed short array1[size]; //256 bytes
   signed short array2[size]; //256 bytes
   float f; //4 bytes
   // a bunch of unsigned short variables of 2 bytes each
   unsigned short m1
   unsigned short m2
   unsigned short m3
   unsigned short m4
   unsigned short m5
   unsigned short m6
   unsigned short m7
   unsigned short m8
} SBinaryMessage69 //Total length is 540 bytes

Each message has a different structure. The binary file does not have any encoding. Is there a way in C++ to convert all the binary data in the .bin file to an ASCII .log file (to be opened in EXCEL later for some analysis- just for information, not included in the scope of question)?

(P.S. I am new to stackoverflow as well, so, sorry if my way of asking the question is wrong!)



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source