I need to create a program that takes input for amount of food eaten by each of 3 monkeys for every day of the week. The input needs to be stored in a two dimensional array. Also, any loops must be contained in secondary functions, and not in main(). I get 2 main errors whenever I try to pass the 2-d array to a function.
1) 31:69: error: too many initializers for ‘char []’
2) 39:35: error: invalid types ‘float[int]’ for array subscript
Can someone tell me what I'm doing wrong? I think I'm incorrectly initializing the array of strings, then incorrectly passing it as a parameter, but I can't seem to figure out the correct way.
#include <iostream> // input/output declarations
#include <iomanip> // i/o manipulator declarations
using namespace std;
const int NUMBER_OF_MONKEYS = 3;
typedef char day[];
void getAmountEaten(float &);
int main()
{
float monkeyFood[NUMBER_OF_MONKEYS][7]; // 3 rows for monkeys, 7 columns for days
getAmountEaten(monkeyFood);
return 0;
}
void getAmountEaten(float &monkeyFood)
{
day dayOfWeek = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
int monkeyNumber,
dayNum;
for (monkeyNumber = 0; monkeyNumber < NUMBER_OF_MONKEYS; monkeyNumber++)
for (dayNum = 0; dayNum < 7; dayNum++)
{
cout << "Enter pounds of food eaten by monkey " << monkeyNumber << "on " << dayOfWeek[dayNum];
cin >> monkeyFood[monkeyNumber][dayNum];
}
}