How would I write a program that scans an entered string for keywords and responds.

I'm attempting to write a program that will respond to me a lot like cleverbot or Siri. I can take care of making the program do the things I want it to do such as shutdown the computer, play a song, or whatever but I do not yet understand how to make it read strings I say, and make sense of them using certain words in that sentence.
I could probably make an endless if statement to see if a string entered (using cin on a string[]) matches a certain other string, covering a million different sentences with a million different combos of words and spelling and capitalization but I want to enter a sentence and have the program search for keywords and then act on them.
For example, with "shutdown" and "computer" being the keywords that make the program run the shutdown operation, so that whether I say "Yo, program, shutdown this computer for me!" or "Shutdown this computer", it will use the common terms here, "shutdown" and "computer" to know what to do.

I have been trying HARD to find a solution and cant, any help would be appreciated!
Use the strstr function from the cstring library. It will return a non-null pointer if the string you're looking for is found in what the user enters, so just check if the value returned by the function is true/greater than zero.

http://www.cplusplus.com/reference/cstring/strstr/
Topic archived. No new replies allowed.