string:find does not return a boolean. that is why it's never gets inside of that second conditional. it returns the index of where it finds the parameter inside of the string.
you're basically comparing an integer == true.
make it compare to -1 (which it returns if it finds nothing) instead of true.
Well, really you should use string::npos to compare against.
That code isn't going to skip non-empty blank lines either.
Suppose your example data has a blank line with spaces or tabs or other whitespace in it!
Yeah, there are a bunch of ways to solve this problem. And it really depends on the intent of the homework question and tools available.
character-level string processing,
Boost style trim and matching,
C++11 regex module use,
or more!
Does that work in G++ yet?
Last time I tried to use it, everything compiled and linked just fine, but the library just returned completely bogus results. Turns out the version of G++ I had didn't support it yet 🙁