fork download
  1. #include<stdlib.h>
  2. #include<stdio.h>
  3. #include<string.h>
  4.  
  5. #ifndef HAVE_STRREV
  6. void strrev(char *s)
  7. {
  8. char t;
  9. int i, len = strlen(s);
  10. for (i = 0; i < --len; ++i) {
  11. t = s[i];
  12. s[i] = s[len];
  13. s[len] = t;
  14. }
  15. }
  16. #endif
  17.  
  18. int main()
  19. {
  20.  
  21. char input[50];
  22. char test[50];
  23.  
  24. int ret;
  25.  
  26. printf("Enter word or phrase to compare ");
  27. fgets(input,sizeof(input),stdin);
  28. strcpy(test,input);
  29.  
  30. strrev(input);
  31.  
  32. ret = strcmp(test,input);
  33.  
  34. if(ret == 0)
  35. printf("\n this is a palindrome ");
  36.  
  37. else
  38. printf("\n this is not a palindrome");
  39. }
Success #stdin #stdout 0s 2172KB
stdin
ala
stdout
Enter word or phrase to compare 
 this is not a palindrome