Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8086315
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T18:24:32+00:00 2026-06-05T18:24:32+00:00

My original problem was how to map multidimensional int array to string.Following was the

  • 0

My original problem was how to map multidimensional int array to string.Following was the solution:thanks to Ikspeto

    map<int , map<int,string>> _myvar;
    _myvar[0][0] = "Some String00";
    _myvar[0][1] = "Some String01";
    _myvar[0][2] = "Some String02";
    _myvar[1][0] = "Some String10";

Now my problem is how to implement find or count method of map on this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T18:24:35+00:00Added an answer on June 5, 2026 at 6:24 pm

    I did not understand your question very well, but I think this is what you are looking for :

    #include <string>
    #include <iostream>
    #include <map>
    
    
    using namespace std;
    
    int main()
    {
       map<int, map<int, string> > m; 
    
       m[0][0] = "one";
       m[1][3] = "two";
       cout<<m[0][0]<<endl;
       cout<<m[1][3]<<endl;
    }
    

    Note that you must leave a blank space after string> .

    or

    If you want to convert every character to int :

    #include <string>
    #include <iostream>
    
    
    using namespace std;
    
    int main()
    {
       string s;
       s = "one";
    
       int arr[2][10];
    
       int a = s.size();
       for(int i=0;i<a;i++)
       {
           arr[0][i] = s[i];
       }
    
       cout<<arr[0][0]<<" "<<(char)arr[0][1]<<endl;
    }
    

    EDIT

    Post your full source code. My example is working at my local compiler. In the code sample you gave you are declaring a variable called _menu_item, but you are using _myvar. You may have declared _myvar differently somewhere in you full code.

    For finding a map entry by the first value you can use find(). Find returns an iterator.

    #include <string>
    #include <iostream>
    #include <map>
    
    
    using namespace std;
    
    int main()
    {
        map<int , map<int,string> > _myvar, my;
        _myvar[0][0] = "Some String00";
        _myvar[0][1] = "Some String01";
        _myvar[0][2] = "Some String02";
        _myvar[1][0] = "Some String10";
    
        map<int , map<int,string> >::iterator it; /* This is an iterator for this kind of map.
        You can use it to assign a position to it from the map. */
    
    
    
        it = _myvar.find(0); //Like this
        _myvar.erase (it); // And use it for example like this
    
    
        _myvar[3] = _myvar.find(0)->second ; // The pointer ->second gives the second value of the map. In this case an another map.
    
    }
    

    For searching by value you can use this :

    for (it = _myvar.begin(); it != _myvar.end(); ++it)
    {
        if (it->second == value)
        {
            key = it->first;
            break;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sometimes i face the following problem : string txt = con.Request.Params[Par_name].ToString();//the original par value
ORIGINAL TEXT REMOVED OK, so I found the original problem thanks to a helpful
I had a problem that was making the original array to change, the curious
It seems to be a problem with magic quotes. The original string just contains
The original problem was how to work with std::map<std::wstring, std::wstring> > in a secure
Original Problem: I have 3 boxes each containing 200 coins, given that there is
Original Problem In building our projects, I want the mercurial id of each repository
Original problem: What is the right column format for a unix timestamp? The net
The code below is (hopefully) a minimized testcase of my original problem. I'm trying
This is a slightly original variation on a common problem. I have a fairly

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.