Few Questions (HW questions already answered by me)

P

padh.ayo

Hi, I just have a few questions maybe you guys can verify for
correctness:
..
------------------------------------------------------------------------------------------------------------------------

21) Show how you would insert a new element "new_element" into a
linked list "my_list"

my_list new_element = my_list->next;

------------------------------------------------------------------------------------------------------------------------

Just for MY verification: If you want to create a link list in C, do
you need a structure all the time? I know how to create it that way,
but just curious if there are any other ways.

Thanks..
 
B

Ben Pfaff

Hi, I just have a few questions maybe you guys can verify for
correctness:
.

21) Show how you would insert a new element "new_element" into a
linked list "my_list"

my_list new_element = my_list->next;

That doesn't insert anything into anything. It's just an
initialization. Presumably my_list is a pointer type.
Just for MY verification: If you want to create a link list in C, do
you need a structure all the time? I know how to create it that way,
but just curious if there are any other ways.

Normally a linked list will include some kind of auxiliary data
in each node, in addition to the linked list pointers themselves.
The way C provides to bind together different types of data items
in a single package is to use a structure.

Other ways may be possible, but they'd probably be much more
awkward. For example, I suppose you could use an array of two or
more pointers to form a linked list node, but it wouldn't
normally be sensible to do so. (I could see a Lisp
implementation in C might want to do that, but even then it might
be better to use a structure.)
 
G

Guest

Hi, I just have a few questions maybe you guys can verify for
correctness:
.
------------------------------------------------------------------------------------------------------------------------

21) Show how you would insert a new element "new_element" into a
linked list "my_list"

my_list new_element = my_list->next;

------------------------------------------------------------------------------------------------------------------------

Are you sure that is the correct answer?
Just for MY verification: If you want to create a link list in C, do
you need a structure all the time? I know how to create it that way,
but just curious if there are any other ways.

There are other ways, but they amount to the same thing. For example,
if your elements are a bunch of pointers, instead of a structure
containing a pointer to the next element and the data pointer, you
could use an array of two pointers, instead of element->next use
element[0], and instead of element->data use element[1]. It would not
be more readable, it would not be more efficient, it would not be a
good idea. But it's possible.
 
B

bogdan

"""(e-mail address removed) ÐÉÓÁÌ(Á):
"""
Hi, I just have a few questions maybe you guys can verify for
correctness:
.
------------------------------------------------------------------------------------------------------------------------

21) Show how you would insert a new element "new_element" into a
linked list "my_list"

my_list new_element = my_list->next;

------------------------------------------------------------------------------------------------------------------------

Just for MY verification: If you want to create a link list in C, do
you need a structure all the time? I know how to create it that way,
but just curious if there are any other ways.

Thanks..




http://magegame.ru/?rf=626f6764616e
 
B

bogdan

Hi, I just have a few questions maybe you guys can verify for
correctness:
.
-------------------------------------------------------------------------------------------------------------------------

21) Show how you would insert a new element "new_element" into a
linked list "my_list"

my_list new_element = my_list->next;

-------------------------------------------------------------------------------------------------------------------------

Just for MY verification: If you want to create a link list in C, do
you need a structure all the time? I know how to create it that way,
but just curious if there are any other ways.

Thanks..

http://magegame.ru/?rf=626f6764616e
 
J

jaysome

That page appears to be blank.

It appears in IE7 under Windows XP. The character encoding is
"Cyrillic (Windows)". There's a graphic of two "Cyrillic" men on the
page, and some input fields for what looks like a username and
password. There is nothing about C at all.
 
C

Christopher Benson-Manica

Ben Pfaff said:
That page appears to be blank.

"bogdan" has made at least three other identical contentless posts to
the group, so it is clearly just another spammer.
 
J

jjds101

Christopher said:
"bogdan" has made at least three other identical contentless posts to
the group, so it is clearly just another spammer.

Looks like it worked too, considering at least 3 people say they've
clicked on the link...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top