strstr函数的使用
其实就是匹配(比KMP简单)
/**匹配l串中是否存在s串并返回s第一次出现的位置**/
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
int main()
{
int k;
char s[50];
char l[100];
strcpy(s, "0");
strcpy(l, "1234567890125498");
printf("%s", strstr(l, s));
return 0;
}
/**匹配s串的位置**/
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
int main()
{
int k;
char s[50];
char l[100];
strcpy(s, "0");
strcpy(l, "1234567890125498");
char *p = strstr(l, s);
k = p - l;
printf("%d", k);
return 0;
}