I'm trying to write a code to take an image as argv[1] and save it in a new file "argv[2]" with the image flipped upside down, but my output does not open with any image viewer
here's my full code. some one help me out please
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
int main(int argc, char *argv[]){
char buffer[256];
FILE *fp1, *fp2;
long int fileSize, lineSize;
if(argc != 3){
printf("Call model: %s <inputFileName> <outputFileName>\n", argv[0]);
exit(0);
}
fp1 = fopen(argv[1], "r");
fp2 = fopen(argv[2], "w");
if(!fp1 || !fp2){
printf("File oupening problem\n");
exit(0);
}
fseek(fp1, 0L, SEEK_END);
fileSize = ftell(fp1);
rewind(fp1);
fseek(fp2, fileSize, SEEK_SET);
while(fgets(buffer, 256, fp1)){
lineSize = strlen(buffer);
fseek(fp2, -lineSize, SEEK_CUR);
fputs(buffer, fp2);
fseek(fp2, -lineSize, SEEK_CUR);
}
fclose(fp2);
fclose(fp1);
}