Question: Hi, I need help making a C++ program that checks if the output is a palindrome. I have another program that I made to check
Hi, I need help making a C++ program that checks if the output is a palindrome. I have another program that I made to check if the output is a palindrome but it is different to the requeriments of this new program so it is confused since it needs to have a structure object and below I have attached the requeriment code. Thanks.
struct StringRec
{
int strLen;
char theStr[256];
};
void AddChar(StringRec& str, char theCh); // adds one character to the string
void OutputString(StringRec str); // outputs the string and the length of the string
bool CheckString(StringRec str); // returns true if string is a palindrome, false otherwise
void main(void)
{
StringRec theString;
char theChar;
theString.strLen = 0;
cout << "Enter a string: ";
cin.get(theChar);
while(theChar != ' ')
{
AddChar(theString, theChar);
cin.get(theChar);
}
OutputString(theString);
if( CheckString(theString) )
cout << " The string is a palindrome";
else
cout << " The string is not a palindrome ";
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
