Return multidimensional array from function

Hi, In my programme, im trying to return a multidimensional array back to main after user's input. However, I cant run the programme after I try to do it. Line 163: Error : invalid conversion from 'int (*) [3] to int () (-fpermissive.)
Here is my code. Would be great if anyone can advice and explanation on this Thanks.

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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#include <iostream> // Pre-processor directive
#include <sstream>
#include <String>
#include <iomanip>

using namespace std;

const int hours = 3;
const int staff = 10;
string artists[staff] ={"Amy","David","John","Helen","Mumu","William","Sunny","Rocky","Benny","Dawn"};
int staffHours[staff][hours] = {{0,0,0},
                                {0,0,0},
                                {0,0,0},
                                {0,0,0},
                                {0,0,0},
                                {0,0,0},
                                {0,0,0},
                                {0,0,0},
                                {0,0,0},
                                {0,0,0}};

//Functions
void showMenu();
int enterPay(int[][hours],int);
void showPay(int[][hours],int);
void checkout();



//Integer Validation
int getInt()
{
    int return_val =0;
    stringstream ss;
    string input;
    cin >> input;
    ss.str(input);
    ss >> return_val;
    if (ss.fail ())
    {
        do
        {
            ss.clear();
            cout <<"This is not a Positive Integer, please re-enter your number: ";
            cin >> input;
            ss.str(input);
            ss>> return_val;
        }
        while (ss.fail());
            }
            return return_val;
}


//Main programme
int main()
{
    int choice; //Menu choice

    //Constants for menu
    const int MENU_ONE =1,
              MENU_TWO =2,
              MENU_THREE =3,
              MENU_FOUR =4,
              MENU_FIVE =5;

    do
    {
     showMenu();
     cin >> choice;

    //Validate choice selected for menu
    while (choice < MENU_ONE||choice >MENU_FIVE)
    {
       cout << "Please enter a valid choice: ";
       cin >> choice;
    }

    if (choice != MENU_FIVE)
    {
        switch (choice)
        {
            case MENU_ONE:
            enterPay(staffHours,staff);
            break;


            case MENU_TWO:
            showPay(staffHours,staff);
            break;


            case MENU_THREE:
            break;


            case MENU_FOUR:
            break;
        }


    }


    } while (choice != MENU_FIVE);

    checkout();
    return 0;
}

void showMenu()
{
    //Create Menu for user
    cout << "Stardust Art Studio \n";
    cout << "====================================\n";
    cout << "1. Enter Pay\n";
    cout << "2. Show Pay Report\n";
    cout << "3. Show Artist with highest pay\n";
    cout << "4. Show Artist with lowest pay\n";
    cout << "5. Quit the menu\n";
    cout << "Please enter your choice: ";

}

int enterPay(int[][hours],int staff)
{
    for (int x=0; x < staff; x++)
    {
        for (int y=0; y < hours; y++)
        {

            cout << "Enter " << artists[x] << "'s hours #" << y+1 << " :";
            staffHours[x][y]= getInt();

            while (staffHours[x][y]<= 0)
            {
            cout << "Please enter a positive integer:";
            staffHours[x][y]= getInt();
            }
        }

        string choiceCont;
        do
    {
		cout << "Do you wish to continue? (Y/N): ";
		cin >> choiceCont;
	} while(choiceCont != "Y" && choiceCont != "y" && choiceCont != "N" && choiceCont != "n");


        if (choiceCont == "Y"|| choiceCont == "y")
        {
        cout << "\n";
        }

        else
        {
        break;
        }

    }

    cout << endl;
    return staffHours;
}
int* enterPay(int[][hours],int);


int* enterPay(int staffHours[][hours],int staff)
{
for (int x=0; x < staff; x++)
{
for (int y=0; y < hours; y++)
{

cout << "Enter " << artists[x] << "'s hours #" << y+1 << " :";
staffHours[x][y]= getInt();

while (staffHours[x][y]<= 0)
{
cout << "Please enter a positive integer:";
staffHours[x][y]= getInt();
}
}

string choiceCont;
do
{
cout << "Do you wish to continue? (Y/N): ";
cin >> choiceCont;
} while(choiceCont != "Y" && choiceCont != "y" && choiceCont != "N" && choiceCont != "n");


if (choiceCont == "Y"|| choiceCont == "y")
{
cout << "\n";
}

else
{
break;
}

}

cout << endl;
return &staffHours[0][0];
}
Thanks for the reply.
May I ask if the return step is necessary?
Ive tried removing it and it still works for the next part as follows

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
void showPay(int[][hours],int staff)
{
     int totalStaffHours=0;


     for (int x=0; x < staff; x++)
    {
        for (int y=0; y < hours; y++)
        {

        totalStaffHours += staffHours[x][y];

        }

    cout << "Total Hours: " << totalStaffHours << endl;


    }

}
In other words, even without the return statement, my array is brought back into the main component and when I activate NO.2 from the menu, the staffHours array will still be brought forward to the showPay function.
So if that's the case whats the point of returning arrays into the main function
Topic archived. No new replies allowed.