473,473 Members | 1,838 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

map<int ,std::string>

2 New Member
Hi I'm a student majoring a computer .

I tried to make a simple hashing table like (int) 1 , (std::string) "One"
There is a problem in using std::map ㅜㅜ


this is a simple code.
PLZ~~Help me :)

Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. #incluce <map>
  3.  
  4. int main()
  5. {
  6.  
  7.     std::map<int ,std::string> test ;     
  8.     test.insert(std::make_pair(1,"as"));
  9.     test.insert(std::make_pair(2,"as"));
  10.  
  11.     std::map<int,std::string>::iterator start = test.begin(); 
  12.     std::map<int,std::string>::iterator last = test.end();
  13.     for(start ; start != last ; ++start )
  14.     {
  15.         std::cout << start->first ;
  16.         std::cout << "\t"  ; 
  17. //    std::cout << start->second <<std::endl; //it does not work 
  18.     }
  19. }
Thank you^^;
Oct 20 '07 #1
2 2302
Ganon11
3,652 Recognized Expert Specialist
When you make the pair to insert, it may be treating "as" as a character array, not a string? That's the only thing I can think of.
Oct 20 '07 #2
Studlyami
464 Recognized Expert Contributor
In your for loop why do you have for(start ; . . . ) as your first parameter. You already initialized it so you don't need anything in that first field.
Oct 22 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Marcelo Pinto | last post by:
Hi all, In a class of mine I tried to use the following member: std::map<std::string, std::set<std::string> > m_files; but I recieved the following error message: mips-tfile,...
3
by: David | last post by:
Hello, I try to store PROLOG_TERMs in a map which is again stored in another map, to realise this I am using a composite key of two strings. The class compiles fine, but when I insert an element,...
1
by: gipsy boy | last post by:
// -- using namespace std; map<string,string> formMap; list<string> formParams; for(list<string>::iterator fit = formParams.begin(); fit!=formParams.end(); fit++) { cout << "key=" << *fit;...
5
by: Peter Jansson | last post by:
Hello, I have the following code: std::map<int,std::set<std::string> > k; k="1234567890"; k="2345678901"; //... std::set<std::string> myMethod(std::map<int,std::set<std::string> > k)...
19
by: Erik Wikström | last post by:
First of all, forgive me if this is the wrong place to ask this question, if it's a stupid question (it's my second week with C++), or if this is answered some place else (I've searched but not...
1
by: Maxwell | last post by:
Hello, I having having oodles of trouble using the std lib in my MC++ (VS.NET 2003) Class library. I figured out a simple sample to reproduce the errors I am having. Create a MC++ (VS.NET 2003)...
0
by: mirkmmd | last post by:
Hi I am new to this site and also to c++. The problem I am facing is that I when I run the following code, I expect to get '"Today is sunny" at the end of the program. And I do get it in Visual...
6
by: Mr. K.V.B.L. | last post by:
I want to start a map with keys but an empty vector<string>. Not sure what the syntax is here. Something like: map<string, vector<string MapVector; MapVector.insert(make_pair("string1",...
7
by: puzzlecracker | last post by:
I need to be able to use map<char, T*>, I can make it std::map<std::string, T*>, however, Key is passed by char, hence I would need to call c_str() all the time. What do you suggest?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.