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.

Recommended Answers

All 2 Replies

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?

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.