I’m trying to print out a list of strings thus:
std::list<String> const &prms = (*iter)->getParams();
std::list<String>::const_iterator i;
for(i = prms.begin(); i != prms.end(); ++i){
log.debug(" Param: %s",*i);
}
But my program crashes saying Illegal Instruction. What am I doing wrong?
*iis aString, not achar *. Iflog.debug()is a function of theprintffamily, you want a zero-terminated string. Depending on how yourStringclass is implemented you might have a function that returns aconst char *.For example with
std::stringthat function isc_str: