I have been following this convention thus far:
std::string line;
while(std::getline(in,line))
{
if(line.size() && line[0] =='#')
continue;
/* parse text*/
}
The obvious drawback is that comment may not begin at the first character, in the case of leading whitespace.
What is the good way to deal with this sort of a thing?
Simple enhancement: you may want to use line.find_first_not_of(” “) to get the first non-whitespace and then check if that is a ‘#’. That would also cover to the zero length case. Something like this fragment:
More info