Strings

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jun 2005
Posts: 11
Reputation: NejiHyuuga is an unknown quantity at this point 
Solved Threads: 0
NejiHyuuga NejiHyuuga is offline Offline
Newbie Poster

Strings

 
0
  #1
Jun 25th, 2005
I have a program that I know I need a string to use. Problem is in class we did a program with strings in which we input one name like "Dan" and another name like "dave" and it would say which is bigger, how many characters are in each ect. This new program I have to ask the user to input a sentecne like.. " This book has ten pages" then it would count the number words and senteces in text. Also I would have to ask the user it for a letter like "a" and it would count the lower and upper case letters. I have a program in VB where i would put "Hello" and it tels me how many times "L" is used. (i cant find that disk )
I am not asking for the whole program need help on how to start it and tips to get me along, because im seriously lost about this whole chapter on strings.
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 232
Reputation: Dogtree is an unknown quantity at this point 
Solved Threads: 3
Dogtree's Avatar
Dogtree Dogtree is offline Offline
Posting Whiz in Training

Re: Strings

 
0
  #2
Jun 25th, 2005
To count the number of words, just count spans of whitespace. Each span of whitespace separates a word. To count the number of sentences, look for punctuation.
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 11
Reputation: NejiHyuuga is an unknown quantity at this point 
Solved Threads: 0
NejiHyuuga NejiHyuuga is offline Offline
Newbie Poster

Re: Strings

 
0
  #3
Jun 25th, 2005
wha??? spans of whitespace? never learned..or heard anything like that.
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 466
Reputation: winbatch is on a distinguished road 
Solved Threads: 18
winbatch's Avatar
winbatch winbatch is offline Offline
Posting Pro in Training

Re: Strings

 
0
  #4
Jun 25th, 2005
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 11
Reputation: NejiHyuuga is an unknown quantity at this point 
Solved Threads: 0
NejiHyuuga NejiHyuuga is offline Offline
Newbie Poster

Re: Strings

 
0
  #5
Jun 25th, 2005
Ok now i understand how to input a string. What about words..this program has to be almsot simlar to microsoft words "word count." I mean I have a program that tells the number of characters in a string. Meaning each letter, but it has to count words a sentence and allow the user to ask for a letter. Then it tells how many times that letter is used.

Now to have it count a sentence I can use a period/ question mark as one of the characters..that way the program will look for a period or question mark and say how many sentences are there. But what about words and letters? It has to be so that the user can type any random sentence and get the number of words in that sentece. I mean it would be easier if it was from file because then i have seen sites that have simliar problems. I ask the professor but he doesnt give me a straight answer. Its annoying and i know i have to figure it out, but without me knowing how to start, it is like im stuck in a ditch. I mean I know the include statemnts to use...just everything else is confusing.
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 232
Reputation: Dogtree is an unknown quantity at this point 
Solved Threads: 3
Dogtree's Avatar
Dogtree Dogtree is offline Offline
Posting Whiz in Training

Re: Strings

 
0
  #6
Jun 25th, 2005
> spans of whitespace?
Whitespace is when you hit the space bar on your keyboard, or the tab key, or the return key. Spans means one or more. So you're looking for one or more of ' ', '\t', '\n', or '\v'.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC