#include<iostream>
#include<string>
#include<cstring>
using namespace std;
const n=100;
const m=50;
int stringmatch(char ch1[],char ch2[])
{
int i,j;
for(i=0;i<n-m;)
{
j=0;
while(j<m&&ch2[j]==ch1[i+j])
{
j=j+1;
if(j=m)
return i;
}
return 0;
}
}
void main()
{
int k;
char c1[n];
char c2[m];
cout<<"请输入第一串字符:"<<endl;
cin.getline(c1,n-1);
cout<<"第一串字符为:"<<c1<<endl;
cout<<"请输入第二串字符:"<<endl;
cin.getline(c2,m-1);
cout<<"第二串字符为:"<<c2<<endl;
k=stringmatch(c1,c2);
if(k==-1)
cout<<"匹配失败!"<<endl;
else
cout<<k<<endl;
}