Given a string , check whether the reverse read of the string is same and print as "palindrome" if it does else print "not a palindrome" using two pointers with one pointer pointing to the starting index of the string and other pointer pointing to the ending index of the string.
#include <stdio.h> int main(void) { char *s,*e,x; int flag=1; s=(char*)malloc(sizeof(char)); scanf("%s",s); e=(s+strlen(s)-1); x=e; if(strlen(s)>2) { while(s!=e && s==x) { if(!(*s==*e)) { flag=0; break; } s++; e--; x=e; x--; } } else if(*s!=*e) flag=0; if(flag) printf("palindrome"); else printf("not palindrome"); return 0; }