Code: Select all
#include <cstdlib>
#include <iostream>
using namespace std;
//structures
typedef struct Tribe
{
int Number;
int Members;
int Men;
int Age;
};
int totalTribes;
//user-defined function declaration
int menuFunction(int a, int b, int c);
int tribalAssignment(Tribe Tribes[], int c);
int main(int argc, char *argv[])
{
int menuChoice;
Tribe Tribes[totalTribes];
menuFunction(menuChoice, Tribes[totalTribes].Members, totalTribes);
system("PAUSE");
return EXIT_SUCCESS;
}
int tribalAssignment(int b, int c)
{
int y = 1;
Tribe Tribes[totalTribes] = b[];
int currentTribe = y;
for(int iCount = 0; iCount <= c; iCount++)
{
Tribes[iCount].Members = 0;
Tribes[iCount].Number = 0;
Tribes[iCount].Men = 0;
Tribes[iCount].Age = 1;
cout << "Tribe number " << Tribes[iCount].Number << " Tribe Members " << Tribes[iCount].Members << endl;
}
}
int menuFunction(int a, int b, int c)
{
cout << "Main Menu..." << endl;
cout << "-------------------" << endl;
cout << " 1. Change Number of People " << b << endl;
cout << " 2. Change Number of Tribes " << c << endl;
cout << " 3. Generate Tribal Assignment" << endl;
cout << " 4. Quit..." << endl;
cin >> a;
switch ( a )
{
case 1 :
cout << "How many people would you like to calculate?" << endl;
cin >> b;
menuFunction(a, b, c);
break;
case 2 :
cout << "How many tribes would you like to calculate for?" << endl;
cin >> c;
menuFunction(a, b, c);
break;
case 3 :
tribalAssignment(b, c);
break;
case 4 :
return EXIT_SUCCESS;
break;
}
}
Tribe Tribes[totalTribes] = b[];
Someone try compiling it and you will see the error. The error it is giving me is: expected primary expression before ] token. I am new to c++ so I am having difficulty with understanding structs and functions and such.