This program is suppose to read a line of text and find out if its a palindrome or not(a palindrome is a line of text that has the same sequence of letters both forward and backward. but so far its only reading one line. and its not getting it right
here's the infile:
Madam I'M Adam.
Nix on NIXON.
A man, a plan, a canal, PANAMA.
"Lager,sir,is regal".
You can cage a swallow can't you? But you can't swallow a cage, can you?
Lisa Bonet ate no basil.
Please i need assistance.....
Thanks for stopping by
//Program Six
//Due Date: 30th April 2010
//This program read
#include<iostream>
#include<fstream>
using namespace std;
bool letter(char ch)
{
return('a'<= ch && ch <= 'z')||('A'<=ch && ch <='Z');
}
int main()
{
ofstream outfile;
ifstream infile;
outfile.open("outfile.txt");
infile.open("infile.txt");
char line[80];
bool palindrome;
char ch;
int little();
int i = 0,size=0;
infile>>ch;
/*while(ch!.eof)*/
while(ch!='.')
{
outfile<<ch;
if(letter(ch))
{
line[i]=/*toupper*/(ch);
i++;
}
infile>>ch;
}
line[i]=line[size-i];
palindrome = true;
for(int i=0; i <=size/2; i++)
if(line[i]=line[size-i])
palindrome=false;
if (palindrome)
outfile<<"is a palindrome"<<endl;
else
outfile<<"is not a palindrome"<<endl;
outfile.close();
infile.close();
}