From 4c4ad2cd9ca85bd1f819408595cedf0a3782a567 Mon Sep 17 00:00:00 2001 From: SileNce5k Date: Sat, 24 Jun 2023 21:26:28 +0200 Subject: [PATCH] add GenerateLineEndings.c --- GenerateLineEndings.c | 52 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 GenerateLineEndings.c diff --git a/GenerateLineEndings.c b/GenerateLineEndings.c new file mode 100644 index 0000000..fab3550 --- /dev/null +++ b/GenerateLineEndings.c @@ -0,0 +1,52 @@ +#include + +int main() { + // Generate LF line endings + FILE* file_lf = fopen("file_lf.txt", "w"); + if (file_lf == NULL) { + printf("Error creating file with LF line endings.\n"); + return 1; + } + + for (int i = 1; i <= 10; i++) { + fprintf(file_lf, "Line %d\n", i); + } + + fclose(file_lf); + + + // Generate CRLF line endings + FILE* file_crlf = fopen("file_crlf.txt", "w"); + if (file_crlf == NULL) { + printf("Error creating file with CRLF line endings.\n"); + return 1; + } + + for (int i = 1; i <= 10; i++) { + fprintf(file_crlf, "Line %d\r\n", i); + } + + fclose(file_crlf); + + + // Generate mixed line endings + FILE* file_mixed = fopen("file_mixed.txt", "w"); + if (file_mixed == NULL) { + printf("Error creating file with mixed line endings.\n"); + return 1; + } + + for (int i = 1; i <= 10; i++) { + if (i % 2 == 0) { + fprintf(file_mixed, "Line %d\r\n", i); + } else { + fprintf(file_mixed, "Line %d\n", i); + } + } + + fclose(file_mixed); + + printf("Files generated successfully.\n"); + + return 0; +}