Re: [OT] C programming, variable size array

From: Debian User (debian-user_at_zerocrossings.com)
Date: 12/12/03

  • Next message: Wesley J Landaker: "Re: [OT] C programming, variable size array"
    To: debian-user@lists.debian.org
    Date: Fri, 12 Dec 2003 15:46:08 -0500
    
    

    if you really have to do it in a low-level language, do it in assembly
    native to that processor. you can even write them inline within your
    C code.

    asm(" mnemonic_instruction operand, operand");

    At Friday, 12 December 2003, Alex Malinovich <demonbane@the-love-
    shack.net> wrote:

    >On Fri, 2003-12-12 at 14:04, Wesley J Landaker wrote:
    >> On Friday 12 December 2003 11:38 am, Aryan Ameri wrote:
    >> > Hi There:
    >> >
    >> > I am a first year CS student, learning C. A while ago I was asked
    >> > this question from a fellow friend of mine:
    >> >
    >> > "Write a program, which promts the uset to enter some numbers. The
    >> > user should terminate the sequence of numbers by entering EOF
    >> > character. The program should put numbers entered by the user
    in to a
    >> > 1D array".
    >>
    >> Hmmm... sounds a lot like a homework problem... =)
    >>
    >
    >Yes, it does... :)
    >
    >> Of course, the normal way to do something like this is to not use C,
    >> since it's way more low-level than you need.
    >
    >But since the OP did say he was a CS major, I'd imagine that the whole
    >point would be to do it in a very low level language. :)
    >
    >> It would be better to allocate memory in chunks, or better yet, do
    >> something like read the numbers into a linked-list and then copy
    them
    >> to an array when you're ready to use them that way, or to use
    C++ and
    >> use the <vector> class, or something like that.
    >
    >I definitely agree with the linked-list suggestion. I had thought that
    >most intro CS courses already cover linked list implementations. Either
    >way, if you haven't had linked lists as part of your curriculum yet,
    >learn how to do them now and it will put you ahead of the game for
    a lot
    >of your courses. The course that I took that introduced linked lists
    >took the better part of the semester to cover them though, in my
    >opinion, one or two labs max would have been sufficient.
    >
    >And I wouldn't even bother putting the linked list into an array in the
    >first place. If you write a good linked list implementation (which,
    as I
    >said, would be a good exercise) it will already support all of the
    >functions that you're likely to need with an array, so you might
    as well
    >just keep it as a linked list.
    >
    >--
    >Alex Malinovich
    >Support Free Software, delete your Windows partition TODAY!
    >Encrypted mail preferred. You can get my public key from any of the
    >pgp.net keyservers. Key ID: A6D24837
    >
    >Attached file
    >Save attachment
    >View attachment as text
    > Name: signature.asc
    > Type: application/pgp-signature
    >
    >

    -- 
    To UNSUBSCRIBE, email to debian-user-request@lists.debian.org 
    with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
    

  • Next message: Wesley J Landaker: "Re: [OT] C programming, variable size array"

    Relevant Pages

    • Re: References as Hash Keys, Tree Structures (Newbie) (Was: simple pointer operations (newbe))
      ... hashed but the hash code returned by that object is used as the index. ... They say quite compactly that a hash is an array of pointers to linked lists ... Which reminds me what's the origin of the term bucket when talking about ...
      (comp.lang.perl.misc)
    • Re: hash tables, non-random keys
      ... That could be a showstopper for linked lists. ... Cost: one pointer per node. ... Another possibility is to use an array. ... In used slots, keep the values, and in unused slots, keep a ...
      (comp.programming)
    • Re: My thoughts on Time/Speed
      ... As I was considering different amounts of exertion, ... One of my rewrites used a priority queue for the schedule. ... My current schedule structure is an array of pointers, ... the timing system to keep the linked lists quite short. ...
      (rec.games.roguelike.development)
    • Re: garbage collection problem in large linked lists
      ... Instead all buckets are allocated at once in an array. ... VG.net, which must be very scalable, but only for lists which would normally ... Linked lists require pointer dereferencing in order to traverse. ... When you run out of space, you allocate a new smaller array. ...
      (microsoft.public.dotnet.framework.performance)
    • Re: Creating an array of objects (newbie question)
      ... in the array with the cell of the array pointing to the head of each ... You'll basically work with an array of linked lists. ... error for another reason (like trying to reference a non-static member ... If my linked list object had a head and node, ...
      (comp.lang.java.programmer)