0

hi,

for( turbo c++)

:eek: is there anyway my program can recognize words :idea: :!: . for eg.

cin.getline(sentence,10); :rolleyes:

"Hello how are you?"

then the program recognises the words - hello, how, are , you and prints "im fine". :)

and if i cin >> " hello how are you, im fine"

and it recognises words " hello , how ,are , you" and print the same messege just by recognising the words in the sentence.

,
cpp noob.

3
Contributors
2
Replies
3
Views
12 Years
Discussion Span
Last Post by winbatch
0

Well how advanced do you want it to be. When somebody types,

What is the reason for OO design?

do you want the program to give an opinionated, zealoted reply?

Or do you just want to search for "hello", "how are you" and if there's a match reply then?

0

A generic way to do this would be to have a file with questions and responses. You can then load the entire file when the program starts into a map<string,string>. Then, you can then search the map for the question and if a response is present, return it. If it's not present, you can ask the user for the appropriate response and then add it to the file for the next time.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.