From 689311b84e7b702fb23c491657c4d7129e4b4109 Mon Sep 17 00:00:00 2001 From: Lucas Date: Thu, 19 Feb 2026 17:51:15 +0100 Subject: [PATCH] write_all_in_one --- .../fundamentals/basic_write/basic_write.c | 24 +++++++++++++++++- .../fundamentals/basic_write/does_exist.txt | Bin 13 -> 16 bytes .../basic_write/still_not_yet_exist.txt | 1 + .../fundamentals/basic_write/test | Bin 16136 -> 16208 bytes 4 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 Who_robbed_Thibouvre/fundamentals/basic_write/still_not_yet_exist.txt diff --git a/Who_robbed_Thibouvre/fundamentals/basic_write/basic_write.c b/Who_robbed_Thibouvre/fundamentals/basic_write/basic_write.c index ca9f137..3894c6a 100644 --- a/Who_robbed_Thibouvre/fundamentals/basic_write/basic_write.c +++ b/Who_robbed_Thibouvre/fundamentals/basic_write/basic_write.c @@ -16,6 +16,15 @@ int write_one_by_one(char *filename, const char *text){ return 0; } +int write_all_in_one(char *filename, const char *text){ + + FILE *file = fopen(filename, "w"); + if(!file)return 1; + + fprintf(file, text); + return 0; +} +/* int main() { // does_exist.txt contains: "something which will be replaced" @@ -30,6 +39,19 @@ int main() // The opening should succeed as it creates the file if needed // However it can fail if the file's access is forbidden + // does_exist.txt contains: "Hello World!" + a = write_all_in_one("does_exist.txt", "What a good day!"); + // does_exist.txt contains: "What a good day!" + + // still_not_yet_exist.txt... does not exist. + b = write_all_in_one("still_not_yet_exist.txt", "Now I exist"); + // still_not_yet_exist.txt... now exists and contains: "Now I exist" + + printf("%d %d\n", a, b); // 0 0 + // The opening should succeed as it creates the file if needed + // However it can fail if the file's access is forbidden + + 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 3615520240bf84fe2471475fd53ce54de9600604..77cf4529b3dff6a9dab35a7371cf08710b07e488 100644 GIT binary patch literal 16 XcmWH~NGwrER7lUyPfU);-(V=20DmcWQ@ z)mo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