Welcome to Dream.In.Code
Become a C++ Expert!

Join 137,229 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,883 people online right now. Registration is fast and FREE... Join Now!




Need some help with string function.

 
Reply to this topicStart new topic

Need some help with string function.

tamil_pride
20 Mar, 2007 - 12:27 PM
Post #1

New D.I.C Head
*

Joined: 11 Mar, 2007
Posts: 5


My Contributions
how do you count the number of words and of a group od characters in programming?

so if i enter for example: Hello My Name Is Bob

it will say: number of words entered is 5.
User is offlineProfile CardPM
+Quote Post

NickDMax
RE: Need Some Help With String Function.
20 Mar, 2007 - 07:39 PM
Post #2

2B||!2B
Group Icon

Joined: 18 Feb, 2007
Posts: 2,859



Thanked: 50 times
Dream Kudos: 550
My Contributions
If we assume that the words are serperated by spaces then we can just tokenize the string (break it up into smaller strings seperated by the spaces) and then count the tokens. The C function strtok() would be able to do this for you.
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/4/08 03:12PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month