#include #include using namespace std; int main() { const char *s; string str; char *found; cout << "Enter a string: "; cin >> str; s = str.c_str(); found = strchr(s, 'a'); cout << "strchr(\"" << s << "\", 'a') returned "; if (found == NULL) { // -OR- if (!found) ... cout << "NULL\n"; } else { cout << '"' << found << '"' << endl; } found = strrchr(s, 'a'); cout << "strrchr(\"" << s << "\", 'a') returned "; if (!found) { cout << "NULL\n"; } else { cout << '"' << found << '"' << endl; } found = strstr(s, "ba"); cout << "strstr(\"" << s << "\", \"ba\") returned "; if (found == NULL) { cout << "NULL\n"; } else { cout << '"' << found << '"' << endl; } return 0; }