C create linked list

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • donbock
    Recognized Expert Top Contributor
    • Mar 2008
    • 2427

    #16
    Originally posted by sedaw
    Code:
        temp=(Node*)malloc(sizeof(Node));
        temp->next=head;
        head=temp;
        printf("Enter coordinate, <x,y>\n");
        scanf("%d,%d",head->x,head->y);
    malloc will return NULL if it is unable to allocate the memory you request. You should always check the return value. If malloc returns NULL then you could [for example] print a message to stderr and invoke exit(1).

    Comment

    • JosAH
      Recognized Expert MVP
      • Mar 2007
      • 11453

      #17
      ... and it's "int main( ... )", not "void main( ... )"; when will you people learn? It even saves one entire keystroke, whick makes millions of keystrokes per year so your keyboard doesn't wear out that much so you save money, reduce your debts and buy your dog a proper meal and more important: it's the Standard! When will you learn instead of act monkey-see-monkey-do with that stupid Microsoft, the source of this silly error!

      kind regards,

      Jos ;-)

      Comment

      • loonman
        New Member
        • Sep 2009
        • 7

        #18
        amen brother!!! heathens! int your main! avoid the void!!

        Comment

        • JosAH
          Recognized Expert MVP
          • Mar 2007
          • 11453

          #19
          Originally posted by loonman
          amen brother!!! heathens! int your main! avoid the void!!
          I know that the OP has sinned father; may I suggest a short and efficient defenestration and afterwards we'll wiggle our genitals towards his general direction so his remains will be in shame on the pavement.

          kind regards,

          Jos ;-)

          Comment

          • loonman
            New Member
            • Sep 2009
            • 7

            #20
            Originally posted by JosAH
            I know that the OP has sinned father; may I suggest a short and efficient defenestration and afterwards we'll wiggle our genitals towards his general direction so his remains will be in shame on the pavement.
            the imagery is so vivid. i totally agree. (wiping tears from my eyes)

            in complete admiration,
            Loon

            Comment

            Working...