/* priklad pr8_4.c citanie po znakoch a cislovanie riadkov (posledny riadok nie) */
#include "stdio.h"
void main(void)
{
FILE *fp;
char c;
int pocet=1;
fp = fopen("S.TXT","r");
if (fp == NULL) printf("File S.TXT doesn't exist\n");
else
{
printf("%d: ",pocet);
do
{
c = getc(fp); /* get one character from the file */
if(c=='\n')
{
c=getc(fp);
if(feof(fp)==0) printf("\n%d: ",++pocet);
ungetc(c,fp);
}
else putchar(c); /* display it on the monitor */
} while (feof(fp) == 0); /* repeat until end of file */
}
fclose(fp);
}