The goal of the program is to read in any file, exe, mp3, etc. and make a working copy of it. Here's my code:
I viewed both the original and the copy in a hex editor and I saw that the copy had several extra 0Ds (hex). There are three possibilities for the problem that I can visualize, I'm reading in the input file incorrectly, I'm outputting the data incorrectly, or both. This problem has stumped me for a while now and I need some help. I hope you guys can help, Thank you!!Code:#include <stdio.h> #include <limits.h> #include <string.h> #define BUFFER 1 #define INPUT input #define OUTPUT output int main(int argc, char *argv[]) { if(argv[1] == NULL) { printf("Format:\n"); printf("Program.exe input.z output.z\n"); return 0; } if(argv[2] == NULL) { printf("Format:\n"); printf("Program.exe input.z output.z\n"); return 0; } if(argv[3] != NULL) { printf("Format:\n"); printf("Program.exe input.z output.z\n"); return 0; } FILE* INPUT; INPUT = fopen(argv[1], "rb"); FILE* OUTPUT; OUTPUT = fopen(argv[2], "w"); while(!feof(INPUT)) { unsigned char* buf = malloc(sizeof(char) * BUFFER); fread(buf, BUFFER, 1, INPUT); int i; for(i = 0; i < BUFFER; i++) fprintf(OUTPUT, "%c", buf[i]); free(buf); } fclose(INPUT); fclose(OUTPUT); return 0; }



2Likes
LinkBack URL
About LinkBacks



