I tried to read and write fild in C but it failed. It partly worked, but the original file and the output file is not same.
I tried to read and write bmp file.
FILE* openFile = fopen(argv[1], "rb");
FILE* writeFile = fopen(strcat(argv[1], ".cpd"), "wb");
fseek(openFile, 0, SEEK_END);
long size = ftell(openFile);
char* bin = (char*)malloc(sizeof(char) * (size + 1));
rewind(openFile);
fwrite(bin, size, 1, writeFile);
//closefile, free, ...
Copyright Notice:Content Author:「Goldenbough」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/59208357/reading-and-writing-binary-file-in-c-language