I am trying to implement a function orWords(string one, string two) where it searches for a user's words. In main the user must type in two words with an "or" in the middle. For example: "run or fast" I cannot figure out what I'm am doing wrong. It doesn't like the bool operators and I can't find how to fix it.
1 2 3 4 5 6 7 8 9 10 11
string x, y;
string w = "or";
cout << "What are your words" << endl;
cin >> x;
cin >> y;
cin >> w;
if (x && w && y)
{
orWords(x, y);
}
My program asks the user to type in words to search for in a group of files, so the user will type in something like "run OR fast" or "run AND fast" so I need to create an if/else statement to determine which function to use to either search for both words are in the documents (AND) or to search whether one or the other word is in the documents (OR).
An if statement is checking something... a good example would be
if(x + w + y = 5)
of course x,w,y would be int.
that code( if(x+w+y) ) doesn't make sense unless it's a boolean expression, which it isn't in this case. if you're wondering how to check if it's and or or, try
You might want to make sure to read in w before you read y, so that x is your first word, w is your and/or, and y is your second word. I think I see what you were trying to do with that cin. :)