#include <stdio.h>
#include <string.h>
#include <ctype.h>//一些用于测试字符的函数
int fun(char *s)
{char *lp,*rp;
/**********found**********/
lp= s ;//指向第一个元素
rp=s+strlen(s)-1;//指向最后一个元素
while((toupper(*lp)==toupper(*rp)) && (lp<rp)) {
/**********found**********/
lp++; rp -- ;}//lp往后移动,rp应该往前移动
/**********found**********/
if(lp<rp) return 0;//如果成立说明lp和rp比较没有比较到字符串的最中间的字符
else return 1;
}
main()
{char s[81];
printf("Enter a string: "); scanf("%s",s);
if(fun(s)) printf("\n\"%s\" is a Palindrome.\n\n",s);
else printf("\n\"%s\" isn't a Palindrome.\n\n",s);
}