WordCount Program

This is a discussion on WordCount Program within the C++ Programming forums, part of the General Programming Boards category; Hey I am looking for a program in C++ that counts the words inputed by a user including any spaces. ...

  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
    Peace
    Join Date
    Aug 2001
    Posts
    1,510
    >>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, 11:04 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21