soluces/c/semaine-4/hidden-message/main.c
2023-11-22 23:07:21 +01:00

34 lines
563 B
C

#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void) {
FILE *file;
size_t length;
char text[500], message[500];
int i;
file = fopen("messageIA.txt", "r");
if (file == NULL) {
printf("failed reading file");
return EXIT_FAILURE;
}
fgets(text, sizeof(text), file);
length = strlen(text);
for (i = 0; i < length; i += 3) {
strncat(message, &text[i], 1);
}
/* I've normalized the file input so o is ô & e is é */
printf("%s", message);
fclose(file);
return EXIT_SUCCESS;
}