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.

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.

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.

> 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'.

This article has been dead for over six months. Start a new discussion instead.