Can anyone please advise wad's wrong with this code...why do i still get 0 despite typing in radar...
Code:1 #include <stdio.h> 2 #include <string.h> 3 4 int isPalindrome1(const char *str); 5 6 int main ( ) 7 { 8 char str [40]; 9 int result; 10 scanf("%s",str); 11 12 result=isPalindrome1(&str); 13 printf("%d",result); 14 15 return 0; 16 } 17 18 int isPalindrome1 (const char *str) 19 { 20 char temp1 [40]; 21 char temp2 [40]; 22 int i=0; 23 int length=0; 24 int result=0; 25 26 strcpy (temp1,str); 27 length=strlen(temp1); 28 for (i=0; i<length; i++) 29 temp2[i]=temp1[length-i]; 30 31 if(strcmp(temp2,str)=='\0') 32 result=1; 33 else 34 result=0; 35 36 return result; 37 }



3Likes
LinkBack URL
About LinkBacks



