summaryrefslogtreecommitdiff
path: root/rushs/tinyprintf/io_merge_files
diff options
context:
space:
mode:
authorMartial Simon <msimon_fr@hotmail.com>2025-09-15 01:08:27 +0200
committerMartial Simon <msimon_fr@hotmail.com>2025-09-15 01:08:27 +0200
commitc9b6b9a5ca082fe7c1b6f58d7713f785a9eb6a5c (patch)
tree3e4f42f93c7ae89a364e4d51fff6e5cec4e55fa9 /rushs/tinyprintf/io_merge_files
add: graphs et rushs
Diffstat (limited to 'rushs/tinyprintf/io_merge_files')
-rw-r--r--rushs/tinyprintf/io_merge_files/merge_files.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/rushs/tinyprintf/io_merge_files/merge_files.c b/rushs/tinyprintf/io_merge_files/merge_files.c
new file mode 100644
index 0000000..26ac9cf
--- /dev/null
+++ b/rushs/tinyprintf/io_merge_files/merge_files.c
@@ -0,0 +1,31 @@
+#define _POSIX_C_SOURCE 200809L
+
+#include <stdio.h>
+
+int merge_files(const char *file_1, const char *file_2)
+{
+ FILE *a = fopen(file_1, "a");
+ if (a == NULL)
+ {
+ return -1;
+ }
+ FILE *r = fopen(file_2, "r");
+ if (r == NULL)
+ {
+ return -1;
+ }
+
+ int c;
+ while ((c = fgetc(r)) != EOF)
+ {
+ if (fputc(c, a) == EOF)
+ {
+ return -1;
+ }
+ }
+
+ fclose(a);
+ fclose(r);
+
+ return 0;
+}