I'm a new at C++ and need some help with this code. I searched but maybe because I'm not familiar with the correct vocabulary for C++, I couldnt' find an answer for this.
What I'm trying to do is pass a string into a function that is looking for an array.
Probably easier for me to show the code then write it out.
Code begins with AppMain()...
Let's say I have this declaration and 4 arrays:
char * theCategory;
char* arrCats[]={"fruits","veggies","colors"};
char* fruits[]={"Apple","Banana","Berry"};
char* veggies[]={"Asparagus","Bell Pepper", "Carrot","Corn"};
char* colors[]={"Aqua","Black","Blue","Brown","Gray"};
Then I have these 3 functions:
void getCatArrAndVals (char* arg[])
{
//do something
}
char * LoadCategory()
{
srand( time(NULL) );
int RandIndex = rand() % 3;
theCategory=arrCats[RandIndex]; //category I'm interested in
getCatArrAndVals(colors); //I'm passing the hard-coded value of "colors" array
//here but I really want to pass theCategory
return theCategory;
}
void AppMain()
{
LoadCategory();
}
How do I pass the string value into the getCatArrAndVals functions as an array?