Re: [OT] C programming, variable size array
From: Debian User (debian-user_at_zerocrossings.com)
Date: 12/12/03
- Previous message: s. keeling: "Re: [OT] C programming, variable size array"
- Maybe in reply to: Aryan Ameri: "[OT] C programming, variable size array"
- Next in thread: Wesley J Landaker: "Re: [OT] C programming, variable size array"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Previous message: s. keeling: "Re: [OT] C programming, variable size array"
- Maybe in reply to: Aryan Ameri: "[OT] C programming, variable size array"
- Next in thread: Wesley J Landaker: "Re: [OT] C programming, variable size array"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|