0

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? And how do i get the program to exclude commas?

3
Contributors
2
Replies
3
Views
10 Years
Discussion Span
Last Post by WaltP
0

You didn't post any code so I am assuming you are just interested in general help.

Check out string.h (they have a nice writeup on Wikipedia) which will give you some ideas about the kinds of string handling functions available in C.

Good luck!

0

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'

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.