strstr()函数的使用

  strstr(str1,str2) 函数用于判断字符串str2是否是str1的子串。如果是,则该函数返回str2在str1中首次出现的地址;否则,返回NULL。

实例:

 1 /**
 2 *Description:strstr()函数的使用
 3 *author:CodingMengmeng
 4 *time:2017-08-18 20:32:22
 5 */
 6 #include <iostream>
 7 using namespace std;
 8 
 9 int main()
10 {
11     char* s = "This is CodingMengmeng!";
12     char* l = "Meng";
13     char* p;
14     p = strstr(s, l);
15     if (p != NULL)
16     {
17         cout << "str=" << p << endl;
18     }
19     else
20     {
21         cout << "Not Found!" << endl;
22     }
23     return 0;
24 }
25 //输出:Mengmeng!
原文地址:https://www.cnblogs.com/codingmengmeng/p/7392095.html