Searching a 2d array and printing results

Hello!

I have a four digit number that I need to search an array for and print a string of words. I've seen a few examples but it was hard to relate it to my project I'm working on. Could someone help me compare my treeData integer to an array? The data will look like "1123" and "Tree information goes here". I need to search using the 1123 and print out "Tree information goes here.".
Here is the code I'm working on.

main
1
2
3
4
5
6
7
8
9
10
11
12
13
#include "include/treedata.h"


int main()
{
    tree_1111 treeInfo;
    int treeForm();
    int treeData=0;
    treeData=treeForm();

    std::cout << treeInfo.getInfo();
    std::cout << treeData << " End of program.";
}


.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#include <iostream>

int treeForm()
{
    int leafChoice=0;
    int veinChoice=0;
    int edgeChoice=0;
    int barkChoice=0;

        std::cout << "Welcome to Tree ID!" << std::endl;
Menu1:
        std::cout << "Please choose the type of leaf to get started." << std::endl << std::endl;
        std::cout << "1. Hand Shaped Leaves" << std::endl;
        std::cout << "2. Spear Shaped Leaves" << std::endl;
        std::cout << "3. Heart Shaped Leaves" << std::endl;
        std::cout << "4. Round Leaves" << std::endl;
        std::cout << "5. Needles" << std::endl;
        std::cout << "6. Quit" << std::endl << std::endl;
        std::cout << "Enter choice: ";
        std::cin >> leafChoice;
        std::cout << std::endl;

    if (leafChoice == 6) return 0;
	while ((leafChoice < 1) || (leafChoice >6)) {
		std::cout << "Invalid input" << std::endl << std::endl;
		std::cout << "Please choose the type of leaf to get started." << std::endl << std::endl;
		std::cout << "1. Hand Shaped Leaves" << std::endl;
		std::cout << "2. Spear Shaped Leaves" << std::endl;
		std::cout << "3. Heart Shaped Leaves" << std::endl;
		std::cout << "4. Round Leaves" << std::endl;
		std::cout << "5. Needles" << std::endl;
		std::cout << "6. Quit" << std::endl << std::endl;
		std::cout << "Enter choice: ";
		std::cin >> leafChoice;
        std::cout << std::endl;
    if (leafChoice == 6) return 0;
	}
Menu2:
        std::cout << "Now let's take a look at the veins, are they:" << std::endl << std::endl;
        std::cout << "1. Netlike?" << std::endl;
        std::cout << "2. Parallel?" << std::endl;
        std::cout << "3. Back" << std::endl << std::endl;
        std::cout << "Enter choice: ";
        std::cin >> veinChoice;
        std::cout << std::endl;

    if (veinChoice == 3) goto Menu1;
    while ((veinChoice < 1) || (veinChoice >3)) {
        std::cout << "Invalid input" << std::endl << std::endl;
        std::cout << "Now let's take a look at the veins, are they:" << std::endl << std::endl;
        std::cout << "1. Netlike?" << std::endl;
        std::cout << "2. Parallel?" << std::endl;
        std::cout << "3. Back" << std::endl << std::endl;
        std::cout << "Enter choice: ";
        std::cin >> veinChoice;
        std::cout << std::endl;
    if (veinChoice == 3) goto Menu1;
    }
Menu3:
        std::cout << "How about the edges of the leaves, are they?" << std::endl << std::endl;
        std::cout << "1. Smooth edges" << std::endl;
        std::cout << "2. Toothed edges" << std::endl;
        std::cout << "3. Lobed edges" << std::endl;
        std::cout << "4. Back" << std::endl << std::endl;
        std::cout << "Enter choice: ";
        std::cin >> edgeChoice;
        std::cout << std::endl;

    if (edgeChoice == 4) goto Menu2;
    while ((edgeChoice < 1) || (edgeChoice > 4)){
        std::cout << "Invalid input" << std::endl << std::endl;
        std::cout << "How about the edges of the leaves, are they?" << std::endl << std::endl;
        std::cout << "1. Smooth edges" << std::endl;
        std::cout << "2. Toothed edges" << std::endl;
        std::cout << "3. Lobed edges" << std::endl;
        std::cout << "4. Back" << std::endl << std::endl;
        std::cout << "Enter choice: ";
        std::cin >> edgeChoice;
        std::cout << std::endl;
    if (edgeChoice == 4) goto Menu2;
    }
        std::cout#include <iostream> << "What does the bark look like?" << std::endl << std::endl;
        std::cout << "1. Smooth" << std::endl;
        std::cout << "2. Scales" << std::endl;
        std::cout << "3. Plates" << std::endl;
        std::cout << "4. Peeling strips" << std::endl;
        std::cout << "5. Shed Ribbon" << std::endl;
        std::cout << "6. Fibrous" << std::endl;
        std::cout << "7. Curved Ridges" << std::endl;
        std::cout << "8. Back" << std::endl << std::endl;
        std::cout << "Enter choice: ";
        std::cin >> barkChoice;
        std::cout << std::endl;

    if (barkChoice == 8) goto Menu3;
    while ((barkChoice < 1) || (barkChoice > 8)){
		std::cout << "Invalid input" << std::endl << std::endl;
        std::cout << "What does the bark look like?" << std::endl << std::endl;
        std::cout << "1. Smooth" << std::endl;
        std::cout << "2. Scales" << std::endl;
        std::cout << "3. Plates" << std::endl;
        std::cout << "4. Peeling strips" << std::endl;
        std::cout << "5. Shed Ribbon" << std::endl;
        std::cout << "6. Fibrous" << std::endl;
        std::cout << "7. Curved Ridges" << std::endl;
        std::cout << "8. Back" << std::endl << std::endl;
        std::cout << "Enter choice: ";
        std::cin >> barkChoice;
        if (barkChoice == 8) goto Menu3;
    }
        std::cout << leafChoice << veinChoice << edgeChoice << barkChoice << std::endl;

        int treeData = leafChoice * 1000 + veinChoice * 100 + edgeChoice * 10 + barkChoice;

        std::cout << treeData << std::endl;

        std::cout << "Leaf Choice = " << leafChoice << std::endl;
        std::cout << "Vein Choice = " << veinChoice << std::endl;
        std::cout << "Edge Choice = " << edgeChoice << std::endl;
        std::cout << "Bark Choice = " << barkChoice << std::endl;

        char retry;
Menu4:
        std::cout << "Try again? (y/n) ";
        std::cin >> retry;

        if ((retry=='n') || (retry=='N')) return 0;
        else if ((retry=='y') || (retry=='Y')) goto Menu1;
        else {
        std::cout << "Please enter a valid input." << std::endl;
        goto Menu4;
             }
        return treeData;
}


Any help would be extremely appreciated, thank you!
First off, you should not be using goto. This is 2017 we use structured programming, not this "spaghetti code"! Its bad practice and just leads to a mess! Next, the array just trying to understand how its setup and I don't see any array in your code. From what you say I envision it as:

|----------------------
| Tree # | Tree info |
|----------------------
| 1124 | Tree info |
|----------------------
| 1123 | Tree info |
|----------------------
| continued |

If this is what it looks like just use a for loop and test the values in the first column. Just stepping through each one is simplest but there are many more complicated but more efficient search algorithms out there.
How do I test for the first value but print the second value? I think I'm a bit lost on the concept. I talked with my professor before using goto and he was okay with it, what's so wrong about it if it's isolated in a function? Sorry, not trying to be difficult or anything!
You can look at each value in the array individually when trying to find the number you want you'll increment your row number, while looking in the first column, till you find what your looking for, then save that number because you can then use that row number but look in the second column for the tree info.
Topic archived. No new replies allowed.