Good eve:
a function searches a string for a substring and returns the sub triggering an event, simply:
I would appreciate some hints (only hints, please) to nudge me in the proper direction to: search said string for not only one word(ex:"dog") but two words (ex:"dog", "cat") I have tried a few methods such as placing additional, uniquely-named var arrays and setting "pch" accordingly (NOTE: the above code ^ does not reflect these stated adjustments-- it failed I believe due to that fact that NULL was returned (?)Code:#include <stdio.h> #include <fstream> #include <iostream> #include <string.h> #include <windows.h> using namespace std; int main() { char resp1[]="good"; char name[256]; cout<< "Hello, how are you today?\n"<< endl; cin.getline (name,256); char * pch; pch=strstr (name, "good"); //Searching for “good” in ^ Char str if(pch !=NULL) cout<< "I am glad to hear you are doing well today."<< endl; else cout<< "Is anything wrong at all? Would you like to discuss it? \n"<< endl; Sleep(50000); return 0; //END }
Any help or encouragement would be greatly encouraged-- you guys are just great
Cheers, reRanger



LinkBack URL
About LinkBacks



