This is my code to take an input and determine if it is a palindrome or not. In my strConvert function I use putchar, but it takes the uppercase letters and lowers then and just puts them in front of the string. I want it to just lower the uppercase letters in the string. I feel my code is pretty close to being correct. Please Help!
#include <iostream>
#include <string>
#include <cctype>
using namespace std;
#include <iostream>
#include <string>
#include <cctype>
usingnamespace std;
bool isPalindrome(string);
void strConvert(string&);
int main() {
//init vars
string str;
//prompt user for palindrome
cout << "Please enter a possible palindrome. ";
cin >> str;
strConvert(str);
cout << str << endl; //test
if (isPalindrome(str))
cout << "That was a Palindrome!";
else
cout << "That was not a Palindrome!";
//pause and exit
return 0;
}
//fuction that detrmines if input is a palindrome or not.
bool isPalindrome(string str) {
for (unsignedint c = 0; c < str.length() / 2; c++)
if (str[c] != str[str.length() - 1 - c])
returnfalse;
returntrue;
}
void strConvert(string &str) {
for (unsignedint c = 0; c <= str.length(); c++)
str[c] = tolower(str[c]);
}