Re: Word counting

From: wave (mutilation_at_bonbon.net)
Date: 12/12/03

  • Next message: amado.alves: "RE: Word counting"
    Date: 12 Dec 2003 01:49:10 -0800
    
    

    Hello again, christ six replies already :)

    I appreciate the feedback so far, and realise that the program I gave
    was a pretty poor attempt at the problem at hand. After a while
    though, of messing about with it, I got tired and just decided to post
    the result I had so far.

    I'll try and respond to all your questions rather than quoting you
    all, bear with me though if I miss someone. All of your help is
    appreciated.

    Regarding the case if this is homework or not, I understand you
    people's stance on this. But you can rest, it is not, but an exercise
    in reading from files. I've been attempting similar programs such as
    extracting specific text from programs separated by comma values and
    other such spaces.

    It's not going very well, if you can tell :)
    I'm missing my fopen commands and tokenize functions from PHP!

    Anyway, I've taken most of your advice and I've rethought the pseudo
    code for the program.

    While not the end of the file
            Read the next line from the file
            Move the cursor one place and if character is within a..Z boundaries
    that character is stored in an array word_length(number) for that word
    length
            if the chracter is a space, then we've hit the end of that word
    length so increment our word length to search for by 1 (number). we've
    also hit the end of a word to increment our word count.
    End of loop;

    Loop through our array elements and hopefully we'll have the words
    with each corresponding length and their numbers.

    This coded correctly, with the input:

    This is an example input file
    it should hopefully work correctly
    but we'll see in a minute.

    should hopefully give us something like:
    (minus the formatting)

    ie words of length 1 / 2 / 3 / 4 / 5 / 6
                                    : 1 / 4 / 2 / 3 / 1 / 2

    I realise this is a complete mess and I'm thinking about scrapping the
    whole thing and starting again. For some reason I'm not managing to
    get my head around it and I'm unsure why.

    I appreciate your patience up to this far.

    Cheers again,
    Mut.


  • Next message: amado.alves: "RE: Word counting"

    Relevant Pages

    • Re: Definition of expression and statement.
      ... The fact that a while loop is recognized ... behavior, e.g., if a is an "int" variable and is initially set to ... The various modifier operators, ... increment and decrement, have TWO uses: ...
      (comp.lang.c)
    • Re: Letter to US Sen. Byron Dorgan re unpaid overtime
      ... it's a for loop in the C sense. ... >> sloppy thinking that results from confusing a programming language ... > The line count increment is necessary because the value is used as an offset ... I really hope you know that the C compiler will generate code to ...
      (comp.programming)
    • Re: Definition of expression and statement.
      ... they end with a semicolon, are not recognized as an "expression" ... The fact that a while loop is recognized ... The various modifier operators, ... increment and decrement, have TWO uses: ...
      (comp.lang.c)
    • Re: New style DO syntax?
      ... Joe Krahn wrote: ... I think that the DO-loop is the only "block construct" that does not contain the 'expression/attribute' part in parenthesis. ... Using parenthesis for delimiters should also allow for using array elements as do iterators. ... Capture the value of I at loop start and use that for ...
      (comp.lang.fortran)
    • Re: The inaugural VB6 vs dot net test
      ... increment a third variable inside the inner loop. ... But I was repsonding to Ulrich's statement about counting down to zero as opposed to counting up to a specific value in order to save a couple of clock cycles. ... WTF is the point of doing that if you are then going to include and additional otherwise unnecessary pointer that gets incremented within the loop, which will eat up as least as many clock cycles as you saved, thereby negating your efforts! ...
      (microsoft.public.vb.general.discussion)