I've been trying to create an array that holds two pieces of data and allows the first column to be searched but print out the second column. I've seen a few examples but I'm still stuck. Could someone show me what the array looks like if the data is
1234 example info
2345 example info
4567 example info
I think I can figure out how to search the array but I'm just not sure how to set it up.
I haven't used map before, that looks interesting. Thanks for the suggestion as well cire, that really helped me out. I think I'll see if I can get it working with the array and then I'll see if I can figure out map.
I seem to be getting a build error stating invalid types for array subscript, could you possibly take a look at my code. I changed it a little bit because my compiler wasn't accepting the code with using leaf_type = std::string. I know this seems to be more of a compiler issue but does the code look okay to you?
std::string tree =
int data = treeData;
for (int* current = &tree; current < tree+5; ++current)
if ((*current) == data)
std::cout << data << " exists with value " << (*current) << '\n';
std::cout << treeData << " End of program.";
Thanks for the tip Thomas, it seems to be printing out all the strings though. Would you recommend putting an if loop in to check for the value I'm looking for? I don't really know how to combine your code with cire's to make the array searchable. Thanks again