473,320 Members | 1,921 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

hash_map and C++ strings

Please help me with this. Does VC's hash_map support C++ strings? If so, why
does the following

hash_map <int, string> hm2;
typedef pair <int, string> pr2;
hm2.insert(pr2(1, "Hello"));
cout << "First key value is " << hm2[1] << endl;

crash at run-time?

--
Jon Cosby

Please do not reply to this email address.
Nov 16 '05 #1
1 1562
Doesn't crash with VC2003 (7.1)

"Jon Cosby" <qw****@abc.net> wrote in message
news:uC*******************@newsread1.news.pas.eart hlink.net...
Please help me with this. Does VC's hash_map support C++ strings? If so, why does the following

hash_map <int, string> hm2;
typedef pair <int, string> pr2;
hm2.insert(pr2(1, "Hello"));
cout << "First key value is " << hm2[1] << endl;

crash at run-time?

--
Jon Cosby

Please do not reply to this email address.

Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Sabrina | last post by:
Can someone help? I have been trying to get the hash_map in C++ for .NET to work with strings and const char*. I am using the const char* as the key and a pointer to another class as the data...
5
by: Charles Herman | last post by:
I have the folowing program: #include <iostream> #include <ext/hash_map> using namespace std; using namespace __gnu_cxx; typedef hash_map<char*, long, hash<char*> > char_hash_t;
3
by: Murali | last post by:
I have a requirement where I have to use two unsigned ints as a key in a STL hash map. A couple of ways to do this is 1. create a struct with two unsigned ints and use that as key (write my own...
2
by: gibffe | last post by:
Hello I have a big problem with hash_map in stl. I'm trying to create hash_map<const char *, char *> map to keep key => val pairs as 4 byte C "strings". Everything is ok when i do let's say...
5
by: peter_k | last post by:
Hi I've defined hash_map in my code using this: ------------------------------------------- #include <string> #include <hash_map.h> & namespace __gnu_cxx {
4
by: lokki | last post by:
Hello, can anybody tell me what's wrong with following example code? char *k, *v; k = new char; strcpy(k, "a2"); v = new char;
1
by: joseysaac | last post by:
i have this code in a archive called ffont.h #ifndef FFONT_H_FILE #define FFONT_H_FILE #include "FBase.h" #include "FShape.h" #include <vector> #include <hash_map>
4
by: James Kanze | last post by:
On Jul 16, 10:53 pm, Mirco Wahab <wa...@chemie.uni-halle.dewrote: It depends. You might like to have a look at my "Hashing.hh" header (in the code at kanze.james.neuf.fr/code-en.html---the...
2
by: marek.vondrak | last post by:
Hi, I am wondering if there are any functional differences between SGI's hash_map and tr1's unordered_map. Can these two containers be interchanged? What would it take to switch from hash_map to...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.