ok i'm stuck at a place i can't think and figure out.
is more like a auto reply thing.
when i key in a question, it suppose to answer me back with an answer that is stored within a file.txt. if question doesn't meet whats in the file.txt, it will just reply back I do not have and answer to it.
Hi;Welcome to use the system
Whats your name;I'm just a system
so now i need to know how or anyone can provide the coding on how to make this part to work. Please people, please help me =)
I suggest you reading and storing questions and answer in a map.
In order to read them you can use getline
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
//Declare the map
//Get a question and an answer
string key, value;
getline(file,key,';');//read the key until a semicolon is found
QA[key] = value;//set the values
//Display the answer corresponding to a given question
map<string,string>::iterator i = QA.find(question);
if ( i != QA.end() )
cout << QA[question];
//Question doesn't exists