strchr和strstr的用法是在字符串中查找指定字符字符串的函数,返回值为第一次查找到该字符的位置指针。
这么说可能不知道返回值运行出来是啥结果,运行一下看看就知道,其实就是查找到该字符以后的所有剩余的字符。
为了简化起见,代码并不是很规范,只是为了演示效果。
#define _CRT_SECURE_NO_WARNINGS
#include
#include
#include
using namespace std;
int main()
{
char s[100] = "helloworld";
char s2[] = "woril";
int a,b;
cout << "======" << endl;
cout<<strchr(s, 'e')<<endl;
cout << strstr(s, "wor") << endl;
return 0;
}