Thread: WordCount Program

  1. #1
    Registered User
    Join Date
    Feb 2002
    Posts
    5

    WordCount Program

    Hey I am looking for a program in C++ that counts the words inputed by a user including any spaces. Usually something like this would give any output statement that tells the user the wordcount. I need this to reference something else for a project. This type of program is common so if anyone can help me out that would be great.

    Thanks
    Jmac

  2. #2
    Pygmy Monkey ErionD's Avatar
    Join Date
    Feb 2002
    Posts
    408
    strtok() might work.
    Look it up.

  3. #3
    >>words inputed by a user including any spaces

    Do you mean letters? If so just use strlen() or something. If you actually meant words separated by spaces then use strcspn() to search for spaces and figure out the count that way.
    "There's always another way"
    -lightatdawn (lightatdawn.cprogramming.com)

  4. #4
    Registered User
    Join Date
    Jan 2002
    Posts
    63
    you're right it is common.. i posted about it a few weeks back.. strtok() is the answer.

    GL
    SS3X

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Issue with program that's calling a function and has a loop
    By tigerfansince84 in forum C++ Programming
    Replies: 9
    Last Post: 11-12-2008, 01:38 PM
  2. Need help with a program, theres something in it for you
    By engstudent363 in forum C Programming
    Replies: 1
    Last Post: 02-29-2008, 01:41 PM
  3. Replies: 4
    Last Post: 02-21-2008, 10:39 AM
  4. Replies: 3
    Last Post: 03-04-2005, 02:46 PM
  5. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM