|
-
May 25th, 2007, 02:11 AM
#1
Map Stl
i have a map stl which goes like this---
map<String, int> *l_NetworkMap
i want to access the required m_Msisdn from the NetworkMap.
i have used find() and end() in this manner
map<string, int>::iterator pos;
pos = l_NetworkMap->find(string((char *)m_Msisdn));
if(l_NetworkMap.end() != pos)
{
......................................
/* remaining code */
}
but still i face a problem ..its core dump.
i am deriving this from a proc function which goes like this
refreshnetworkdetails((map<Str... int>) *m_arg)
where in i store all msisdns from the database into the NetworkMap.
-
May 25th, 2007, 02:16 AM
#2
Re: Map Stl
whoops sorry, I didnt see that last little bit. What is the "..."?
-
May 25th, 2007, 02:23 AM
#3
Re: Map Stl
 Originally Posted by srisravi
i have a map stl which goes like this---
map<String, int> *l_NetworkMap
i want to access the required m_Msisdn from the NetworkMap.
i have used find() and end() in this manner
map<string, int>::iterator pos;
pos = l_NetworkMap->find(string((char *)m_Msisdn));
if(l_NetworkMap.end() != pos)
{
......................................
/* remaining code */
}
but still i face a problem ..its core dump.
i am deriving this from a proc function which goes like this
refreshnetworkdetails((map<Str... int>) *m_arg)
where in i store all msisdns from the database into the NetworkMap.
I see String and string types. I suppose to be a mistake when you write this example.
I don't see any other mistake, and i think the core is not a consecuence of the sencentes you write.
Have you analized the core dump for finding the concrete sentence that generates that core?
Have you seen what kind of core it is? (Segment violation, ....)
-
May 25th, 2007, 03:28 AM
#4
Re: Map Stl
It will unless you actually create a map object. This - map<String, int> *l_NetworkMap - does not create the map object, just a pointer referring to I don't know what.
Can you help me with my homework assignment?, Before you post!, Use code tags, How to post!, Codeguru technical FAQs, C++ FAQ Lite, Stroustrup: C++ Style and Technique FAQ, Guru of the Week, Comeau C and C++ FAQs, Comeau C++ Templates FAQs, CUJ @ DDJ, Spam threshold
My Blogs : Learning C++ is fun | Abnegator's reflections
Open Threads : C++ Aha! Moments | Nature of work in C++?
-
May 25th, 2007, 05:54 AM
#5
Re: Map Stl
 Originally Posted by exterminator
It will unless you actually create a map object. This - map<String, int> *l_NetworkMap - does not create the map object, just a pointer referring to I don't know what.
hi,
you are right.Its a pointer referring to networkmap into which all msisdns are inserted. i get this map when the application is up, to access it afterwards. when i want to check whether a particualr msisdn is present in that map or not...i want to use that find function.
And i dont want to change that MYSQL function which is as follows:
refreshBlackListDetails(map<string, int>* m_arg)
So how can i access those msisdns?
-
May 25th, 2007, 06:15 AM
#6
Re: Map Stl
 Originally Posted by Carlos Martinez
I see String and string types. I suppose to be a mistake when you write this example.
I don't see any other mistake, and i think the core is not a consecuence of the sencentes you write.
Have you analized the core dump for finding the concrete sentence that generates that core?
Have you seen what kind of core it is? (Segment violation, ....)
hi,
the application gives a core dump in the following manner:
Program terminated with signal 11, Segmentation fault.
Cannot access memory at address 0xb7600cc4
#0 0x080765dc in std::_Rb_tree<std::string, std: air<std::string const, int>, std::_Select1st<std: air<std::string const, int> >, std::less<std::string>, std::allocator<std: air<std::string const, int> > >::find (this=Cannot access memory at address 0xb432e6d4
) at stl_tree.h:1267
1267 _Link_type __y = _M_header; // Last node which is not less than __k.
(gdb) bt
#0 0x080765dc in std::_Rb_tree<std::string, std: air<std::string const, int>, std::_Select1st<std: air<std::string const, int> >, std::less<std::string>, std::allocator<std: air<std::string const, int> > >::find (this=Cannot access memory at address 0xb432e6d4
) at stl_tree.h:1267
Cannot access memory at address 0xb432e6cc
-
May 25th, 2007, 01:09 PM
#7
Re: Map Stl
The error is as stated -- somewhere you are accessing invalid memory.
You posted 3 or 4 lines of code that doesn't really show us anything. There is no way you can get help with the such little information. Program crashes can only be diagnosed properly with the entire code being seen and run.
Regards,
Paul McKenzie
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|