I'm having an issue with my palindrome program. I believe it's only determining if the first letter matches the last. I assume this because the entries in my string "race car" and "race casr" both claim to be palindromes. I'm looking for a fix for this:
Code:#include<iostream> #include<conio.h> using namespace std; #include<string> int main() { int i=0; char str[100], c; cout<<"Enter a word/words"<<endl; if(str[i] == ' ') { str[i]='\b'; } cin.getline(str, 100); int s=strlen(str)-1; while(str[i]) { c=str[i]; putchar(tolower(c)); i++; } for(int y=0; y<1; y++) { if(str[y]==str[s-y]) { cout<<""<<endl; cout<<"The word(s) "<<str<<" is a palindrome"<<endl; } else { cout<<""<<endl; cout<<"The word(s) "<<str<<" is not a palindrome"<<endl; } } getch(); }