Results 1 to 6 of 6

Thread: C preallocating an array to zero not working

Hybrid View

  1. #1
    Join Date
    Feb 2007
    Location
    NZ
    Beans
    89
    Distro
    Ubuntu 11.10 Oneiric Ocelot

    C preallocating an array to zero not working

    as seen in attachment. I cannot figure out what I've done wrong.
    Attached Images Attached Images

  2. #2
    Join Date
    May 2007
    Beans
    251

    Re: C preallocating an array to zero not working

    Code:
    counts[letter]
    ??

    Your index variable is i - not letter.
    letter runs from 65 (i = 0) .... 91 (i = 26).

    There is no problem with the allocation - it's the printing that's messed up.
    The Unforgiven

  3. #3
    Join Date
    Feb 2007
    Location
    NZ
    Beans
    89
    Distro
    Ubuntu 11.10 Oneiric Ocelot

    Re: C preallocating an array to zero not working

    OMG I cannot believe I missed it. I spent hours looking at that.

    Thanks

  4. #4
    Join Date
    May 2008
    Location
    UK
    Beans
    1,451
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: C preallocating an array to zero not working

    When posting code in future - use the code tags (the # button on the toolbar), rather than posting a screen shot .

    Also - can you mark this thread as solved - go to Thread Tools.
    Tony - Happy to try to help.
    Unless otherwise stated - all code posted by me is untested. Remember to Mark the Thread as Solved.
    Ubuntu user number # 24044 Projects : TimeWarp - on the fly Backups

  5. #5
    Join Date
    May 2007
    Beans
    251

    Re: C preallocating an array to zero not working

    BTW, to keep it more readable, you could've also done:
    Code:
    letter = i + 'A';
    just so that it's explicitly stated what you're trying to do
    The Unforgiven

  6. #6
    Join Date
    Feb 2007
    Location
    NZ
    Beans
    89
    Distro
    Ubuntu 11.10 Oneiric Ocelot

    Re: C preallocating an array to zero not working

    ok thankyou

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •