int main(void)
{
int ch;
char buf[64];
FILE *fp = fopen("d:\\data.txt","rt");
if (fp == NULL)
{
perror("Error open file");
return 1;
}
while (!feof(fp))
{
ch = getc(fp);
if (ch == EOF) break;
// replace A with 3 // first char only
if (ch == 'A')
ungetc('3', fp);
else
ungetc(ch, fp);
if (fgets(buf, 64, fp) != NULL)
fputs(buf, stdout);
else
break;
}
fclose(fp);
return 0;
}
/*
run:
3BCDEFGHIJKLMNOPQRSTUVWXYZ
*/