// cp // implemented with fgetc // ./a.out data.txt data2.txt // diff data.txt data2.txt // ./a.out lecf lecf2 // diff lecf lecf2 // diff give output if our imp is broken. #include int main(int argc, char *argv[]) { if (argc != 3) { fprintf(stderr, "Usage: %s \n", argv[0]); return 1; } FILE *input_stream=fopen(argv[1],"r"); if (input_stream == NULL){ perror("ERROR"); return 1; } FILE *output_stream=fopen(argv[2],"w"); if (output_stream == NULL){ perror("ERROR"); return 1; } int c; while((c=fgetc(input_stream))!=EOF) { fputc(c, output_stream); } fclose(input_stream); fclose(output_stream); return 0; }