I wanted to take a file (text or binary) and fragment it into small pieces of a certain size (about 250-500kB), randomize the order of the fragments, and put it into another temporary fragmented file.
The un-fragmenting would then take the fragmented file, extract the pieces, put them in order and allow the original file to be intact.
This would be very easy for simple text-based ASCII files as you could use the C library functions (like sscanf) for formating/parsing the information. The one file could have a format then like
(#### <fragment #> <fragment> ...)
However, I am not sure how one would do something like that with binary files.
I know one easy solution is to use separate files for the fragments like <.part1, .part2> files but this would be a bit ugly and wouldn't scale well to much larger files. It would be a lot better to just store it in one file.
Thanks a lot.
sscanf
as before. You should look atfread
(cplusplus.com/reference/cstdio/fread) for handling binary data directly. – Dave 19 hours ago