User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C section within the Software Development category of DaniWeb, a massive community of 455,964 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,630 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C advertiser: Programming Forums
Views: 476 | Replies: 2
Reply
Join Date: Nov 2007
Posts: 18
Reputation: xeto is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
xeto xeto is offline Offline
Banned

Re: Terminating a String

  #1  
Nov 20th, 2007
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?
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Nov 2007
Posts: 19
Reputation: danzona is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 3
danzona danzona is offline Offline
Newbie Poster

Re: Terminating a String

  #2  
Nov 20th, 2007
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!
Reply With Quote  
Join Date: May 2006
Posts: 2,779
Reputation: WaltP is a splendid one to behold WaltP is a splendid one to behold WaltP is a splendid one to behold WaltP is a splendid one to behold WaltP is a splendid one to behold WaltP is a splendid one to behold WaltP is a splendid one to behold 
Rep Power: 15
Solved Threads: 229
Moderator
WaltP's Avatar
WaltP WaltP is offline Offline
Posting Maven

Re: Terminating a String

  #3  
Nov 20th, 2007
Originally Posted by xeto View Post
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()

Originally Posted by xeto View Post
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'
Age is unimportant -- except in cheese
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb C Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the C Forum

All times are GMT -4. The time now is 9:03 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC