This is a bit more preprocessing than a parsing issue. In any case, there are many tools and commands that specialize in doing just what you ask. If possible, it is best to use them.
If you need or want to do this inside your code, than the usual method for this, as already mentioned, save the current state in yours and process any new character in accordance with the state. This is a very good general method, and it is highly recommended, especially there is a lot of preprocessing that needs to be done.
If, however, this is absolutely the only thing you need to do, than you can do something a little better and abandon the state with this code:
do { // Initialize things (buffer for the characters maybe) per line ch = fgetc(input_file); while ( (ch != EOF) && (ch != '\n') && (ch != '#') ) // Assuming
source share