Hi,
I'm trying to write a method that gets a vector of strings and returns a pointer to a random element. Can you please tell what is the problem with the following code?
string* getRandomOption(vector<string> currOptions){
vector<string>::iterator it;
it=currOptions.begin();
string* res;
int nOptions = currOptions.size();
if(nOptions != 1){
int idx = rand() % (nOptions-1);
while (idx!=0){
it++;
idx--;
};
};
res = &(*it);
};
Thanks, Li