I train myself in building a compiler. When I read the file I sometimes need to look a few characters ahead of my current position to know which token I have to generate.
There are two options that come to my mind in that case:
getc(file);
and in case I have to go back to some previous character I use fseek(file, -1, SEEK_CUR);
Which one of these options is more efficient? Which would you prefer?
Thanks for the comments. My decision is to just read the file entirely first and then later check if I run into any performance issues.