is this true ? ;D
Code:
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
using namespace std;
ifstream fin;
ofstream fout;
bool PalindromeChecker(string inputString)
{
int i=0;
int length = inputString.length();
char temp[255] = {'\0'};
for (i=0; i<length; i++)
{
if ((temp[i] >= 'a') && (temp[i] <= 'z'))
temp[i] = char(int(temp[i]) - 32);
}
for (i=0; i<length; i++)
{
if ((temp[i] < 'A') || (temp[i] > 'Z'))
{
for (int j=i; j<length; j++)
{
temp[j] = temp[j+1];
}
i--;
length--;
}
}
int checkLength = length - 1;
if ((checkLength == 0) || (checkLength == 1))
return true;
for (i=0; i<=checkLength/2; i++)
{
if (temp[i] != temp[checkLength-i])
return false;
}
return true;
}
void printAnswer(string input, bool isit)
{
if (isit == true)
cout << input.data() << " is a palindrome." << endl;
else
cout << input.data() << " is not a palindrome." << endl;
}
int main()
{
string inputString;
bool isPalindrome = true;
fin.open("palindromes.txt");
fout.open("output.txt");
if (!fin.good())
throw "I/O Error!";
if (!fout.good())
throw "I/O Error!";
while (fin.good())
{
getline(fin,inputString);
isPalindrome = PalindromeChecker(inputString);
printAnswer(inputString,isPalindrome);
}
fin.close();
fout.close();
return 0;
}

