A couple other things worth noting:
1: do{}while((c = fgetc(input)) != '\n');
Why a do-while? Why not just while((c = fgetc(input)) != '\n');
??
2: fseek(input, -1, SEEK_CUR);
Why? Can't you do something better/cleaner than messing with the file pointer?
It looks like you're already handling the case without the fseek()
.
3: printf("%c", c);
This is a very expensive statement to use for character output. It's much cleaner to use putchar()
.