help on palendromes

bothie's Avatar
Go4Expert Member
can you assist me with a c++ code that will verify whether an input word or sentence is a PALENDROME.Detailing it as much as you could
0
pradeep's Avatar, Join Date: Apr 2005
Team Leader
Here is the C program to check whether a string is palindrome or not.

Code: C
#include<stdio.h>
 #include<string.h>
 #define size 26 // u can set the maximum allowable size of the string here
 
 void main()
 {
     char strsrc[size];
     char strtmp[size];
 
     clrscr();
     printf("\n Enter String: ");
     gets(strsrc);
 
     strcpy(strtmp,strsrc); // create a copy
     strrev(strtmp); // reverse the copied string
 
     if(strcmp(strsrc,strtmp)==0) // compare the two strings
         printf("\n Entered string \"%s\" is palindrome",strsrc);
     else
         printf("\n Entered string \"%s\" is not    palindrome",strsrc);
 
     getch();
 }
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Just an offtopic comment
Offtopic comment:
Its palindrome and not palendrome.
0
bothie's Avatar
Go4Expert Member
thanx ,for the correction ,does the 'strrev' function exists in c++