string parameter and comparison

1
2
3
4
5
6
7
8
9
//Expand
vector<string> expand(string* input)
{
  string options[6];
  
  //<ABCDP,>
  if (input.compare("ABCDP,") == 0) options = {"AB,CDP","AC,BDP","AD,BCP","BC,ADP","CD,ABP","BD,ACP"};
  
//code continues after this 


I'm not sure how to get the comparison to work at "input.compare("..."

I appreciate any help. Also, if I simply return the options variable as I set it above, will that work with the vector<string> return type?

Thank you much
Check this: http://cplusplus.com/reference/string/string/compare/

No, options is an array of string and the function's return type is a vector<string> so that will not work.
Last edited on
string::compare is for three-way comparison. You only need a boolean comparison, so if(*input == "ABCDP,")

(incidentally, why is the function taking a string* parameter? Use const string& input, then the comparison becomes the usual if(input == "ABCDP,")
Topic archived. No new replies allowed.