Code:#include <stdio.h> #include <string.h> int main(){ char string1[20]; int i, length; int flag = 0; printf("Enter a string: "); scanf("%s", string1); length = strlen(string1); for(i=0;i < length ;i++){ if(string1[i] != string1[length-i-1]){ flag = 1; break; } } if (flag) { printf("%s is not a palindrome ", string1); } else { printf("%s is a palindrome ", string1); } return 0; }
Hey guys, I have a program that takes a string and says if it is a palindrome or not. Right now it is case sensitive (Pop would not count as a palindrome) and it also disregards spacing (p o p is a palindrome). How do I change it so that Pop WOULD count as a palindrome and p o p WOULD NOT count as one? Pretty much what do I need to do to make it case insensitive and also make it so that if there are spaces, it does not count as a palindrome? Thanks for any help.