41 lines
624 B
C
41 lines
624 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);
|
|
while(c != EOF){
|
|
printf("%c", c);
|
|
c = fgetc(file);
|
|
/*
|
|
while(c != '\0'){
|
|
c = fgetc(file);
|
|
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;
|
|
}
|
|
*/
|