|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
stl map find function
Hi,
I am trying to figure out how to see if a find in a map didn't find what I was looking for....if i do: map<....>::iterator it = NULL; it = mapInstance.find("hello"); and suppose "hello" doesn't exist in the map, then how will I know?? 'it' will not point to NULL if the find is unsucessful, am I correct? How can I figure out the sucess of the find? THanks, Kavi |
|
#2
|
||||
|
||||
|
The find function returns an interator to the specified key. If the key isn't found, then it returns an iterator to the end of the map.
So... Code:
if (it != mapInstance.end ())
{
// Key found
}
else
{
// Key NOT found
}
__________________
Jon Sagara "Me fail English? That's unpossible!" |
|
#3
|
|||
|
|||
|
Thanks
Thanks for ur help, Jon!
![]() Kavi |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > C Programming > stl map find function |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|