diff --git a/Who_robbed_Thibouvre/fundamentals/basic_write/basic_write.c b/Who_robbed_Thibouvre/fundamentals/basic_write/basic_write.c index d1b45a2..ca9f137 100644 --- a/Who_robbed_Thibouvre/fundamentals/basic_write/basic_write.c +++ b/Who_robbed_Thibouvre/fundamentals/basic_write/basic_write.c @@ -1,14 +1,18 @@ - - - #include + int write_one_by_one(char *filename, const char *text){ - FILE *file = fopen(filename, "rw"); + FILE *file = fopen(filename, "w"); if(!file) return 1; - - + int index = 0; + while(*(text + index) != '\0'){ + fputc(*(text + index ), file); + index ++; + } + //fputc(*text, file); + fputc('\0', file); + fclose(file); return 0; } diff --git a/Who_robbed_Thibouvre/fundamentals/basic_write/does_exist.txt b/Who_robbed_Thibouvre/fundamentals/basic_write/does_exist.txt index d55703e..3615520 100644 Binary files a/Who_robbed_Thibouvre/fundamentals/basic_write/does_exist.txt and b/Who_robbed_Thibouvre/fundamentals/basic_write/does_exist.txt differ diff --git a/Who_robbed_Thibouvre/fundamentals/basic_write/does_not_exist.txt b/Who_robbed_Thibouvre/fundamentals/basic_write/does_not_exist.txt new file mode 100644 index 0000000..ce1bea1 Binary files /dev/null and b/Who_robbed_Thibouvre/fundamentals/basic_write/does_not_exist.txt differ diff --git a/Who_robbed_Thibouvre/fundamentals/basic_write/test b/Who_robbed_Thibouvre/fundamentals/basic_write/test new file mode 100755 index 0000000..9857cff Binary files /dev/null and b/Who_robbed_Thibouvre/fundamentals/basic_write/test differ