So my program is a palindrome checker function using only the string library and C++ sting objects. In order to check if the string input by the user is a palindrome, I need to convert the entire string to lowercase and remove the spaces to check if the string and its reverse are equal. I've tried looking up solutions but I've only found answers using different libraries and creating new functions. This is the code I have so far.
#include <iostream>
#include <string>
using namespace std;
string checkPalin();
int main()
{
string result = checkPalin();
cout << "The palindromes are: " << result;
}
string checkPalin()
{
int stringNum, time = 0;
string list;
string str1;
string reverse;
cout << "How many strings? " << endl;
cin >> stringNum;
cout << "Enter the strings: " << endl;
do
{
getline(cin, str1);
int size = str1.length();
for (int i = size - 1; i >= 0; i--)
reverse += str1[i];
if ((str1.compare(reverse)) == 0)
{
list += str1;
}
time++;
} while (time <= stringNum);
return list;
}