Re: [Dev-C++] Dev-cpp-users Digest, Vol 28, Issue 5
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
From: <ma...@in...> - 2008-09-23 12:50:28
|
On Tuesday 23 Sep 2008 5:40:32 pm dev...@li... wrote: > Send Dev-cpp-users mailing list submissions to > dev...@li... > > To subscribe or unsubscribe via the World Wide Web, visit > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > or, via email, send a message with subject or body 'help' to > dev...@li... > > You can reach the person managing the list at > dev...@li... > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Dev-cpp-users digest..." > > > Today's Topics: > > 1. Pointer and vector (Ricardo Schmidt) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Mon, 22 Sep 2008 14:55:55 -0300 > From: "Ricardo Schmidt" <sup...@gm...> > Subject: [Dev-C++] Pointer and vector > To: dev...@li... > Message-ID: > <db9...@ma...> > Content-Type: text/plain; charset=ISO-8859-1 > > Hello all, > > I am having a little problem that is turning me crazy!!! > > Well, I declared a hash table ht, using std::map, with a key of type > string, and content of type a vector of string: > sdt::map<string, vector<string>*> ht; > > > After inserting values into ht, I want to access the records. So, to > access the data I have the key and I found the its respective line in > ht. I did the following: > > std::map<string, vector<string>* >::iterator temp; //temporary structure > temp = ht.find(id); > > > Now, I want to access the data that is inside the vector that is the > second element in my hash table. I've been trying many ways to do > this, but without success. One of the ways I tried is the following: > > vector<string> data; //vector to store the data from the hash table > data.at(0) = temp->second->at(0); > > Try something like this. vector<string> ::iterator tmp = ht->second.begin(); while(tmp!=ht->second.end()){ std::cout<<*tmp; tmp++; } > It returns me an error like: > > terminate called after throwing an instance of 'std::out_of_range' > what(): vector::_M_range_check > > > Does anybody know what could be the problem here?! > > Thanks in advance for any help. > > Ricardo. > > > > ------------------------------ > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's > challenge Build the coolest Linux based applications with Moblin SDK & win > great prizes Grand prize is a trip for two to an Open Source event anywhere > in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ > > ------------------------------ > > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > > End of Dev-cpp-users Digest, Vol 28, Issue 5 > ******************************************** -- ---------------------------------------------------------------------------- Regards Mayank Jain Nawal ma...@in... http://www.niksun.com Tel: +91 9818390836 +91 124-2316012(109) |