mardi 18 juin 2019

How to iterate over alphabets and use it to construct a string in C++

I am trying to iterate from A to F and construct a string to pass to a function that looks up a hash (string => int) and returns an int value. I tried the following (I also tried char):

int find_int_val (std::string select){... }
std::string links ("ABCDEF");
for ( std::string::iterator link_itr = links.begin(); link_itr != links.end(); ++link_itr) {  
        std::string field = "LINK_" + *link_itr + "_SEL";
        int val = find_int_val(field);
...
}

Aucun commentaire:

Enregistrer un commentaire