//Declaration: int ungetc(int ch, FILE *stream);
//Return: returns ch on success or EOF on failure.
#include
int main ()
{
FILE * filep;
int c;
char buffer [256];
filep = fopen ("testfile.txt","rt");
if (filep==NULL)
perror ("Error opening file");
else {
while (!feof (filep))
{
c=getc (filep);
if (c == '#')
ungetc ('@',filep);
else
ungetc (c,filep);
fgets (buffer,255,filep);
fputs (buffer,stdout);
}
}
return 0;
}