strstr函数字符串匹配问题
题目链接:http://acm.sdut.edu.cn/onlinejudge2/index.php/Home/Index/problemdetail/pid/2772.html
AC代码:
#include<bits/stdc++.h>
using namespace std;
char s1[1000000],s2[1000000];
int main()
{
while(~scanf("%s%s",s1,s2))
{
char *temp=strstr(s1,s2);
if(temp==NULL)
printf("-1\n");
else
printf("%d\n",temp-s1+1);
}
return 0;
}