TP 12 exo3: Add a basic exercice skeleton for file copy and CLI
[TD_C.git] / TP_12 / exo3 / exo3.c
diff --git a/TP_12/exo3/exo3.c b/TP_12/exo3/exo3.c
new file mode 100644 (file)
index 0000000..3e5560a
--- /dev/null
@@ -0,0 +1,22 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+int main(int argc, char** argv) {
+    char* fnamesrc = (char*)argv[1], fnamedest = (char*)argv[2];
+    FILE* fpsrc, fpdest;
+
+    if (argc < 3) {
+        puts("Please enter two arguments separated by a space: file_name_src file_name_dest");
+        exit(EXIT_FAILURE);
+    }
+
+    fpsrc = fopen(fnamesrc, "r"); /* read mode */
+    if (fpsrc == NULL) {
+        perror("Error while opening the source file.\n");
+        exit(EXIT_FAILURE);
+    }
+
+    fclose(fpsrc);
+
+    return EXIT_SUCCESS;
+}