两个字符串 大神进来!
#include <stdio.h>#include <string.h>
char * fun (char *s, char *t )
{
char *p , *r, *a;
/************found************/
a = NULL;
while ( *s )
{ p = s; r = t;
while ( *r )
/************found************/
if ( *r == *p )
{ r++; p++; };
if ( *r == '\0' ) a = s;
s++;
}
return a ;
}
main()
{
char s[100], t[100], *p;
printf("\nPlease enter string S :"); scanf("%s", s );
printf("\nPlease enter substring t :"); scanf("%s", t );
p = fun( s, t );
if ( p ) printf("\nThe result is : %s\n", p);
else printf("\nNot found !\n" );
}
题目要求是 输入两个字符串 如s:ljdfjgl t:fj 则输出fjgl 再如:输入s:fiufhgu t:uf 则输出ufhgu 上面的程序只差一个语句就能完成,哪位大神第一个看出来 小弟把分全部给他!!