Most of the log files produced in system are either in binary(0,1) or hex(0x) formats. Sometimes you might need to map this data into readable format.
Conversion of this hex information into system defined data types such as ‘int/string/float’ is comparatively easy. On the other hand when you have some user defined data types such as ‘struct’ the process can be complicated.
Following basic program will help you with above mentioned operation. While implementing in real world you need more error handling.
After conversion from struct to hex string: 0x01 0x00 0x00 0x00 0x52 0x6f 0x68 0x69 0x74 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 After Conversion form hex to struct: Id : 1 Name : Rohit
This article is contributed by Rohit Kasle. If you like GeeksforGeeks and would like to contribute, you can also write an article and mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above