RosettaCodeData/Task/Palindrome-detection/C/palindrome-detection-2.c
Ingy döt Net b83f433714 tasks a-s
2013-04-10 23:57:08 -07:00

10 lines
264 B
C

int palindrome(const char *s)
{
const char *t; /* t is a pointer that traverses backwards from the end */
for (t = s; *t != '\0'; t++) ; t--; /* set t to point to last character */
while (s < t)
{
if ( *s++ != *t-- ) return 0;
}
return 1;
}