hi, im writing a program that asks how you are feeling, and instead of hard coding all of the keywords (eg: "great") and using
found=x.find(a);
if (found>0)
{
cout << "ok.\n";
goto end1; \\to go to the end of the block
}
to find it in the string, i would like to know how i could write all of the words in a text file and then if one of the words in the file is found in the string it would give the response. basicly to replace the found thingy with a search in a text file.
i have read the whole manual, but i was hoping for some more in-depth help, with things such as how i would include this into an if/else control structure.
So you read an input string from the user. Then you loop through the file, reading each string key in turn and use an if statement to check if the user input equals the file string. If it does then you need to grab your output string from the file as well.
If you show us what you've got so far, it would make it easier for us to help you improve your code.
So you read an input string from the user. Then you loop through the file, reading each string key in turn and use an if statement to check if the user input equals the file string. If it does then you need to grab your output string from the file as well.
If you show us what you've got so far, it would make it easier for us to help you improve your code.
how would i do that? ill post all of the code later i dont have access too it right now =(