Home C C++ Java Python Perl PHP SQL JavaScript Linux Selenium QT Online Test

Home » Forum » x-Forum » Question

Find the value of array in map-CppBuzz-Forum

#include <iostream>
#include <map>

using namespace std;
static const int16_t Val[10] =
{
	0xC18, 0xC23, 0xC26, 0xC29, 0xC2C, 0xC37, 0xC3A, 0xC3D, 0xC40, 0xC4B,
};
static const int16_t Val_[10] =
{
	0x040, 0x043, 0x046, 0x04A, 0x04D, 0x050, 0x053, 0x056, 0x05A, 0x05D,
};
typedef std::map<std::string,  int16_t>fruit;
static const fruit red={
    {"step1", Val[10]},
    {"step2",Val_[10]},
};
int main()
{
    int b;
    std::string step_;
    cout<<"enter step"<<endl;
    cin>>step_;
    cout<<"enter number"<<endl;
    cin>>b;
    cout<<red.at(step_)[b];

i want to find the value of array in b.

What I have tried:

cout<<red.at(step_)[b];
what is wrong in here ?

Posted by naresh. 2020-12-08 23:58:37

No Ans Posted

Please login to comment

Log In


Ask New Question