I am having a problem with writing from one file to another, especially the last value, which is end of file, prints out as question mark in a black square.
My code is supposed to replace text on some conditions which works perfectly just the last value which is EOF is making a little problem.
Any ideas?
input file
Hi, this is *list* version v2.
Contains 8 words. 123
output file
___, _____ ___ *_____* _____ ___.
_____ ___ _____. ___�
C source file
int main()
{
FILE *li, *sa;
li = fopen("list.txt", "r");
sa = fopen("sablona.txt", "w");
int c, poc = 0;
char a[3] = "___";
char b[5] = "_____";
while ( ! feof(li) > 0 ) {
c = getc(li);
if ( isalnum(c) )
poc++;
else if ( poc > 0 && poc < 4 ) {
fputs(a, sa);
poc = 0;
}
else if ( poc >= 4 ) {
fputs(b, sa);
poc = 0;
}
if ( ! isalnum(c) )
putc(c, sa);
}
fclose(li);
fclose(sa);
return 0;
}