diff --git a/Who_robbed_Thibouvre/fundamentals/print_lines/print_lines.c b/Who_robbed_Thibouvre/fundamentals/print_lines/print_lines.c index e69de29..c60c5b0 100644 --- a/Who_robbed_Thibouvre/fundamentals/print_lines/print_lines.c +++ b/Who_robbed_Thibouvre/fundamentals/print_lines/print_lines.c @@ -0,0 +1,34 @@ +#include + +int print_lines(const char *filename){ + + FILE *file = fopen(filename); + if(!file) return 1; + + // int c = fgetc(file); + int c = fgetc(file); + while(c != EOF){ + + while(c != '\0') printf("%c", c); + printf("\n"); + } + + + return 0; +} + +int main() +{ + print_lines("example.txt"); + /* Expected: + > First line + > Second line + > Third line + > and so on + > + > ^^^ Even empty lines ^^^ + */ + + return 0; +} +