For custom binary file you could and should use sqlite, it has many benefits instead of writing your own custom file format. You just have acid without any cost. It's a single file database you can access throuhg lib statically linked in your application and that's done.
You can check these links:
https://sqlite.org/appfileformat.html
https://sqlite.org/aff_short.html