Ignoring lines in an input file

My program reads input from a file, and I want to be able to ignore comment lines (marked with a '#') in the file, but I'm not sure what the best way to go about this is.

So, for example, if the file looks like this:
1
2
3
abcd
#comment
efgh


The program would store abcd in a string, ignore the second line, and then store efgh in another string.

Thanks in advance!
Last edited on
Keep iterating through each character you grab and if the last character was a newline ('\n'), and the current character a hash ('#') than keep iterating through the file, but don't actually continue to grab characters until you find another newline character.
Thanks. That was simple enough. I don't know why I didn't think of that myself.
Topic archived. No new replies allowed.