I have a palindrome program.Is there a way to ensure user input terminated in a string by a punctuation mark (e.g. ‘!’, ‘.’, or ‘?’.) in an array?
Get the length or the string, check the last character with the function ispunct()
And how do i get the program to exclude commas?
Copy the input line to a temp line. Use isalpha() to check if the character is a letter and copy only letters. If you want letters and numbers, use alnum() . This will exclude all non-palindrome characters.
Last thing, make sure when you do the copy you convert all the letters to upper or lower case (use toupper() or tolower() ). This is because 'A' != 'a'