Few Questions (HW questions already answered by me)

Discussion in 'C Programming' started by padh.ayo@gmail.com, Dec 5, 2006.

  1. 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;

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

    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..
    , Dec 5, 2006
    #1
    1. Advertising

  2. Ben Pfaff Guest

    writes:

    > 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.)
    --
    int main(void){char p[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.\
    \n",*q="kl BIcNBFr.NKEzjwCIxNJC";int i=sizeof p/2;char *strchr();int putchar(\
    );while(*q){i+=strchr(p,*q++)-p;if(i>=(int)sizeof p)i-=sizeof p-1;putchar(p\
    );}return 0;}
    Ben Pfaff, Dec 5, 2006
    #2
    1. Advertising

  3. wrote:
    > 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.
    =?utf-8?B?SGFyYWxkIHZhbiBExLNr?=, Dec 6, 2006
    #3
  4. bogdan 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;
    >
    > ------------------------------------------------------------------------------------------------------------------------
    >
    > 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
    bogdan, Dec 6, 2006
    #4
  5. Ben Pfaff Guest

    Ben Pfaff, Dec 6, 2006
    #5
  6. bogdan Guest

    On 6 äÅË., 02:39, wrote:
    > 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
    bogdan, Dec 6, 2006
    #6
  7. pete Guest

    Ben Pfaff wrote:
    >
    > "bogdan" <> writes:
    >
    > > http://magegame.ru/?rf=626f6764616e

    >
    > That page appears to be blank.


    In my browser,
    it looks like ululations with a Portuguese accent.

    --
    pete
    pete, Dec 6, 2006
    #7
  8. jaysome Guest

    On Tue, 05 Dec 2006 17:24:24 -0800, Ben Pfaff <>
    wrote:

    >"bogdan" <> writes:
    >
    >> http://magegame.ru/?rf=626f6764616e

    >
    >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.

    --
    jay
    jaysome, Dec 6, 2006
    #8
  9. Ben Pfaff <> wrote:

    > "bogdan" <> writes:


    > > http://spammed.url.elided


    > 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.

    --
    C. Benson Manica | I *should* know what I'm talking about - if I
    cbmanica(at)gmail.com | don't, I need to know. Flames welcome.
    Christopher Benson-Manica, Dec 6, 2006
    #9
  10. santosh Guest

    Ben Pfaff wrote:
    > "bogdan" <> writes:
    >
    > > http://magegame.ru/?rf=626f6764616e

    >
    > That page appears to be blank.


    He's already spammed this group with that exact post about ten times
    already.
    santosh, Dec 6, 2006
    #10
  11. Guest

    Christopher Benson-Manica wrote:
    > Ben Pfaff <> wrote:
    >
    > > "bogdan" <> writes:

    >
    > > > http://spammed.url.elided

    >
    > > 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.


    Looks like it worked too, considering at least 3 people say they've
    clicked on the link...
    , Dec 6, 2006
    #11
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. kayodeok
    Replies:
    1
    Views:
    343
  2. SithVegeta

    Just need a few questions answered...

    SithVegeta, Nov 15, 2004, in forum: C Programming
    Replies:
    6
    Views:
    369
    SithVegeta
    Nov 15, 2004
  3. Murali
    Replies:
    2
    Views:
    541
    Jerry Coffin
    Mar 9, 2006
  4. Syam
    Replies:
    25
    Views:
    823
    Kai-Uwe Bux
    Dec 2, 2006
  5. x

    questions not being answered

    x, Sep 30, 2003, in forum: ASP .Net Mobile
    Replies:
    3
    Views:
    117
    Kenny
    Oct 9, 2003
Loading...

Share This Page