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
2026-02-23 09:52:40 +01:00

46 lines
738 B
C

#include <stdio.h>
int print_lines(const char *filename){
FILE *file = fopen(filename, "r");
if(!file) return 1;
// int c = fgetc(file);
int c = fgetc(file);
printf("> ");
while(c != EOF){
//if (c == '\n') printf("\n> ");
printf("%c", c);
if(c == '\n') printf("> ");
c = fgetc(file);
/*
while(c != '\0'){
c = fgetc(file);
printf("%c", c);
}
printf("\n");
*/
}
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;
}
*/