My assignment in my class is to create a palindrome program for any given string. The main function is supposed to call an integer function named InputString that reads the characters of length n and it needs to determine if its a non-zero length. If this is so, another function named PalindromeTest is called to test if its a palindrome The returned value here is boolean. Then, from within PalindromeTest, I have to call another function, PrintMessage, upon return from PalindromeTest to display the result of the test.
I am open to any help or suggestions or criticism.
#include <iostream>
#include <cstring>
using namespace std;
#define false 0
#define true 1
char s[100];
char sr[100];
void InputString();
bool PalindromeTest();
void PrintMessage();
int main()
{
InputString();
system("PAUSE");
return 0;
}
void InputString(int n=0)
{
cout<<"Input the string you wish to be tested";
cin.getline(s, 100);
if(strlen(s)>n)
PalindromeTest();
}
bool PalindromeTest()
{
bool rvalue = true;
strcpy(sr, s);
strrev(sr);
if(strcmp(s, sr)==0)
{
rvalue=true;
PrintMessage();
}
else
{ rvalue=false;
PrintMessage();
}
}
void PrintMessage(bool rvalue)
{
if(true == rvalue)
cout<<"The entered string IS a palindrome"<<endl;
else
cout<<"The entered strins IS NOT a palindrome"<<endl;
}