Here is a C program that will merge binary files. Specify the source files followed by the output file.
// bin_merge.cpp : Interleaved merge of binary files
#include <stdio.h>
#include <stdint.h>
int main(int argc, const char* argv[])
{
if (argc < 3) return -1;
int const step = argc - 2;
printf("%i files to merge\n", step);
int size = 0;
uint8_t *rb = 0;
uint8_t *wb = 0;
for (int i = 0; i < step; ++i) {
printf("%s\n", argv[1 + i]);
FILE *f = fopen(argv[1 + i], "rb");
if (!f) { printf("Unable to open file\n"); return -2; }
if (!rb) {
fseek(f, 0, SEEK_END);
size = ftell(f);
rewind(f);
if (size < 1) { fclose(f); return -3; }
printf("size: %i\n", size);
rb = new uint8_t[size];
wb = new uint8_t[size * step];
}
fread(rb, size, 1, f);
uint8_t *s = rb; uint8_t *d = wb + i; int j = size;
do *d = *s++, d += step; while (--j);
fclose(f);
}
delete rb;
FILE *f = fopen(argv[argc - 1], "wb");
fwrite(wb, size, step, f);
fclose(f);
delete wb;
return 0;
}
Source and windows executable attached.