标签:
#include<stdlib.h>
#include<stdio.h>
char* string_in(char *s1,char *s2)
{
char *temp1=s1;
char *temp2=s2;
char *temp=s1;
int inword;
while(*s2!=‘\0‘&&*s1!=‘\0‘)
{
if(*s1==*s2)
{
inword=1;
s1++;
s2++;
}
else
{
inword=0;
s1++;
s2=temp2;
}
if(!inword)
{
temp=s1;
}
}
if(*s2==‘\0‘&&inword)
return temp;
else
return NULL;
}
int main()
{
while(1)
{
char a[30],b[30];
printf("字符串1\n");
gets(a);
printf("字符串2\n");
gets(b);
char *c=string_in(a,b);
if(c)
printf("包含\n");
else
printf("不包含\n");
printf("字符串1包含的开始地址为%p,字母为%c\n",c,*c);
}
}
标签:
原文地址:http://www.cnblogs.com/HJL085/p/5346358.html