I'm pretty new to programming and I'm having a hard time with this assingment. The details are,
Read in each line and determine if it is a palindrome(same word if reversed ie "dad".
The file contains
5 level 5 -"a palindrome"
Madam - "a palindrome"
a&%_$#()V$)(*_A -"a palindrome"
palindrome - "not a palindrome"
The lines are read in regardless of white space, capitalization, or punctuation marks.
The code so far reads in the first line makes all the letters lower case and the takes out all of the punctuation ( I'm only using a&%_$#()V$)(*_A as input at the moment .the output should be ava but i get avavava and I can't figure out why
Any help will be greatly appreciated
there is a recent post regarding palindromes on this board. You can either search each of the last 3 - 4 pages one by one, or use the search feature to go back even further.
//Use the strlen function here
> for(int index=0;index<MAX;index++) //reads in line and converts to lower
for(int index=0;index<strlen(input);index++) //reads in line and converts to lower
> for(int index2=0;index2<MAX;index2++) // takes out everything but letters
for(int index2=0;index2<strlen(input);index2++) // takes out everything but letters
Yikes! That array is 'strlened' every pass. Better would be
int i = strlen(input);
for(int index = 0; index < i; index++)
Thanks for the help I ran the for loops to strlen and zero'd out the test array after each pass through the while loop.
It works like a champ
Again thanks for the info