for ( string::iterator ch = str.begin(); ch != str.end(); c++ ) {
if (*ch == "A") // error
s = *ch;
if (s == "A") // works
}
for ( string::iterator ch = str.begin(); ch != str.end(); c++ ) {
if (*ch == "A") // error
s = *ch;
if (s == "A") // works
}
for ( string::iterator ch = str.begin(); ch != str.end(); c++ ) {
if (*ch == 'A')
do_stuff();
if(ch == "foo")
do_other_stuff(); // Not sure if this would work, but it would make sense.
}
int main( void )
{ CHAR_DATA *ch, *next;
char_list = char_free = NULL;
new_char("Davion");
new_char("Ralgith");
new_char("Quixadhaul");
new_char("Jonny");
for(ch = char_list ; ch ; ch = next )
{ printf("%s\r\n", ch->name);
next = ch->next;
//blow stuff up
if(ch->next && !strcasecmp(ch->next->name, "Ralgith") )
free_char(ch->next);
}
return -1;
}
You could probably setup a loop to call a function to grab the next iterator.