C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 1st, 2003, 11:10 PM
kavi_s kavi_s is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2003
Posts: 24 kavi_s User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #2  
Old July 2nd, 2003, 12:07 AM
jonsagara's Avatar
jonsagara jonsagara is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2001
Location: USA
Posts: 286 jonsagara User rank is Private First Class (20 - 50 Reputation Level)jonsagara User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 7 m 23 sec
Reputation Power: 7
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!"

Reply With Quote
  #3  
Old July 2nd, 2003, 09:59 AM
kavi_s kavi_s is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2003
Posts: 24 kavi_s User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks

Thanks for ur help, Jon!

Kavi

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > stl map find function


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway