Hi, I need some help with reading in 1 mb of binary data, and writing it to a different file. I want to continue this until the whole file has been read and written to the new one. I've searched around and I have found nothing useful. Thank you for taking the time to look.
Code:#include <stdio.h> int main(int argc, char *argv[]) { FILE *fp; FILE *out; size_t = result; int size = 1024 * 1024; // 1 mb int i; char *buffer; out = fopen("file.bin", "wb"); for(i = 0; i < argc; i++) { fp = fopen(argv[i + 1], "rb"); while(!feof(fp)) { result = fread(buffer, size, 1, fp); if(result != size) Error("Could not load into memory\n"); if( fwrite(buffer, 1, size, out) != size) Error("Error writing file to bin\n"); free(buffer); } fclose(fp); } getchar(); return 0; }