So I need to display a table with all of the categories such as housing, transportation, etc along with the other information in each of the arrays that I've initialized. I can't seem tot figure out how to display individual array elements using the "displayTable" function. When I say "cout << housing[0] << " " << utilities[0]" and so on I keep getting a build error. I've tried different syntax as well but I just can't figure it out. It's for an assignment in one of my classes. Any help is much appreciated!
#include <iostream>
#include <iomanip>
using namespace std;
struct Category
{
string category;
double maxAmount;
double amountSpent;
};
void displayTable(Category housing[3], Category utilities[3],
Category transportation[3], Category food[3],
Category entertainment[3], Category miscellaneous[3])
{
cout << setprecision(2)
<< housing[0];
}
int main()
{
int menuChoice;
Category housing = {"Housing", 500.00, 0.00};
Category utilities = {"Utilities", 150.00, 0.00};
Category transportation = {"Transportation", 50.00, 0.00};
Category food = {"Food", 250.00, 0.00};
Category entertainment = {"Entertainment", 150.00, 0.00};
Category miscellaneous = {"Miscellaneous", 50.00, 0.00};
do
{
} while (menuChoice != 3);
return 0;
}