#include #include int main(int argc, char *argv[]) { FILE *src, *dst; int ch; // Check if correct number of arguments is provided if (argc != 3) { printf("Usage: %s \n", argv[0]); return 1; } // Open source file in read mode src = fopen(argv[1], "r"); if (src == NULL) { perror("Error opening source file"); return 1; } // Open destination file in write mode dst = fopen(argv[2], "w"); if (dst == NULL) { perror("Error opening destination file"); fclose(src); return 1; } // Copy contents from src to dst character by character while ((ch = fgetc(src)) != EOF) { fputc(ch, dst); } printf("File copied successfully from %s to %s\n", argv[1], argv[2]); // Close both files fclose(src); fclose(dst); return 0; }