#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Location
    Maryland
    Posts
    2
    Rep Power
    0

    Unhappy functions I need help


    I have a prgram that I am writing the function reads and writes blanks. Whenever it hits a nonblank, except for whitespace characters, like tab etc, it increments the number of words on a line. At first reading the assignment my thought was that it would count blanks. It is reading from an input file and writing to an output file. Now if my file reads something like this
    My name is Name and I live somewhere.
    Wouldn't it read each character as a word?? See I thought that it would look for blanks, so it would read a charater than go to the next until it got to a blank than that would tell it that it had read a word
    example of the code I have not finished it yet just starting to get a feel

    char processBlank(char& blanks)
    {
    int bcounter;
    char blanks;
    char notext;

    inputsource>>notext;

    for(bcounter = 1; blanks == ' '; bcounter ++)


    }
  2. #2
  3. I'm Baaaaaaack!
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Jul 2003
    Location
    Maryland
    Posts
    5,538
    Rep Power
    244
    I think your logic will count all non-blank characters in your input. You will probably want to consider flags to indicate if you are in a word or in a series of blanks.

    My blog, The Fount of Useless Information http://sol-biotech.com/wordpress/
    Free code: http://sol-biotech.com/code/.
    Secure Programming: http://sol-biotech.com/code/SecProgFAQ.html.
    Performance Programming: http://sol-biotech.com/code/PerformanceProgramming.html.
    LinkedIn Profile: http://www.linkedin.com/in/keithoxenrider

    It is not that old programmers are any smarter or code better, it is just that they have made the same stupid mistake so many times that it is second nature to fix it.
    --Me, I just made it up

    The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man.
    --George Bernard Shaw

IMN logo majestic logo threadwatch logo seochat tools logo