Linked list question.

This is a discussion on Linked list question. within the C Programming forums, part of the General Programming Boards category; For $20 dollars, I'll post all 10,000 lines of this engineering wonder. The question comes on how the node gets ...

  1. #1
    Registered User
    Join Date
    Jan 2006
    Location
    Berkeley, Ca
    Posts
    195

    Linked list question.

    For $20 dollars, I'll post all 10,000 lines of this engineering wonder. The question comes on how the node gets allocated.

    Code:
    struct node {
     int scores;
     int *next;
    };
    
    typedef N_TYPE n_type;
    
    /*skip 500 lines */
    
    node ->next = malloc(sizeof *node->next);
    Maybe I'm being dense, but why not go something like:

    node->next = malloc(sizeof(struct node));

  2. #2
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,699
    >> For $20 dollars, I'll post all 10,000 lines of this engineering wonder.

    a twenty dollar visual assault? I'll pass.

    >> why not go something like:

    that would be a clearer way to do it.
    Code:
    bool fun(bool value)
    {
        return std::pow(std::exp(1), std::complex<float>(0, 1) 
        * std::complex<float>(std::atan(1)*(1 << (value + 2))))
        .real() > 0;
    }

  3. #3
    Registered User
    Join Date
    Jan 2006
    Location
    Berkeley, Ca
    Posts
    195
    So going like

    Code:
    node ->next = malloc(sizeof *node->next);
    Is supposed to make the intent more clearer than going something like

    Code:
    node ->next = malloc(sizeof (struct node));

  4. #4
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,699
    no, I meant the other way around.
    Code:
    bool fun(bool value)
    {
        return std::pow(std::exp(1), std::complex<float>(0, 1) 
        * std::complex<float>(std::atan(1)*(1 << (value + 2))))
        .real() > 0;
    }

  5. #5
    Registered User
    Join Date
    Mar 2006
    Posts
    725
    Depends on what you mean by "clear". I do agree with you on that one, though.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Linked List Not Saving Value as Int
    By bar338 in forum C Programming
    Replies: 4
    Last Post: 05-04-2009, 07:53 PM
  2. linked list question
    By brb9412 in forum C Programming
    Replies: 16
    Last Post: 01-04-2009, 03:05 PM
  3. singly linked circular list
    By DarkDot in forum C++ Programming
    Replies: 0
    Last Post: 04-24-2007, 08:55 PM
  4. singly linked list
    By clarinetster in forum C Programming
    Replies: 2
    Last Post: 08-26-2001, 10:21 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21