fork download
  1. #include <iostream>
  2. #include <string>
  3.  
  4.  
  5. int main() {
  6. using leaf_type = std::string[2];
  7.  
  8. leaf_type tree[5] =
  9. {
  10. {"1234", "1234-abcde"},
  11. {"2345", "2345-bcdef"},
  12. {"3456", "3456-cdefg"},
  13. {"4567", "4567-defgh"},
  14. {"5678", "5678-efghi"},
  15. };
  16.  
  17. auto data = "3456";
  18.  
  19. for (auto* current = &tree[0]; current < tree+5; ++current)
  20. {
  21. if ((*current)[0] == data) {
  22. std::cout << data << " exists with value " << (*current)[1] << '\n';
  23. break;
  24. }
  25. }
  26. }
Success #stdin #stdout 0s 4288KB
stdin
Standard input is empty
stdout
3456 exists with value 3456-cdefg