help with using associative containes ( map )

blork98's Avatar, Join Date: Jan 2007
Newbie Member
Hi, guys.... trying to write a function that checks to see if a number already exists in a vector...

anyway, the function returns true if the number does not exist and false it it does not.
the parameter const string& word is the key to the map

my problem is that the program crashes. if i take out this function, then it works fine, as long as i dont use it in the main program. i think the problem is in the for loop, because the program again works fine if i comment out the for loop.

thanks in advance for any help.. hope i described the prob ok

HTML Code:
bool is_not_present( const map<string, vector<int> >& r, const int& line, const string& word)
{
     map<string, vector<int> >::const_iterator i = r.find(word);
     bool flag = true;
     for( vector<int>::const_iterator it = i->second.begin(); it != i->second.end(); ++it ){ 
          if(  *it == line) flag = false;    
     }
     return flag;          
}
blork98's Avatar, Join Date: Jan 2007
Newbie Member
never mind, he he dumb mistake