一道简单的C语言编程题,高手请进!在线等!!!

用指针完成函数strend(s,t),若字符串t出现在字符串s的末尾,函数返回1,否则返回0.

第1个回答  2007-06-23
#include"stdio.h"
#include"string.h"
int strend(char s1[50],char s2[50]);
void main()
{
char st1[50],st2[50];
printf("please input a string:");
scanf("%s",st1);
printf("please input a short string:");
scanf("%s",st2);
printf("%d",strend(st1,st2));
}
int strend(char s1[50],char s2[50])
{
char *p1,*p2;
int m,i;
m=strlen(s2);
p1=s1;
p2=s2;
while(*p2!='\0')
p2++;
p2--;
while(*p1!='\0')
p1++;
p1--;
for(i=1;i<=m;i++)
if(*p1!=*p2)
return 0;
else
{
p1--;
p2--;
}
return 1;
}
相似回答