C program to Check if a string is palindrome using Pointers

 

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char *sk, *rk;
int i,j;
clrscr();
sk=(char*)malloc(50);
rk=(char*)malloc(50);
printf("Enter a String: ");
gets(sk);
i=strlen(sk)-1;
j=0;
while(i>=0)
{
*(rk+j)=*(sk+i);
j++;
i--;
}
*(rk+j)='\0';
if(strcmp(sk,rk)==0)
printf("%s is a Palindrome String",sk);
else
printf("%s is not a Palindrome String",sk);
getch();
}

 

 

Output:

C program to Check if a string is palindrome using Pointers