This repository has been archived on 2026-05-11. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
prog-103-p-05-2030/Who_robbed_Thibouvre/fundamentals/hidden_message/hidden_message.c
T
2026-02-23 09:46:54 +01:00

52 lines
991 B
C

#include <stdio.h>
int hidden_message(const char *filename, const char delim){
FILE *file = fopen(filename, "r");
if(!file) return 1;
int c = fgetc(file);
if (c != EOF) putchar(c);
//char *cara = c;
while(c != EOF){
c = fgetc(file);
if( c == delim){
while(c == delim) c = fgetc(file);
if (c != EOF && c != delim)putchar(c);
}
}
fclose(file);
return 0;
}
/*
int main()
{
hidden_message("example.txt", ':'); // Must return 0.
// Must print nook
putchar('\n');
hidden_message("example.txt", ';'); // Must return 0.
// Must print: n
// Because no delimiter was found, so only the first character is printed
putchar('\n');
hidden_message("does_not_exist.txt", ':'); // Must return 1.
// Must not print anything
// FLAG
//Decode the given message to understand what it means
//
hidden_message("flag.txt", '~');
return 0;
}
*/