Results 1 to 3 of 3

Thread: structures as parameter

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2004
    Location
    San Isidro
    Posts
    326

    structures as parameter

    it says argument list syntax error in the line colored red...whats wrong with my code??
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    
    typedef struct
    {
        int x;
        struct node *next;
    }node;
    
    node nd;
    
    void insert_list(nd **head, int num)
    {
        nd *p, temp;
        temp = (nd *)malloc(sizeof(nd));
        temp->x = num;
    }
    I want to learn more
    grace

  2. #2
    Fanatic Member twanvl's Avatar
    Join Date
    Dec 2001
    Posts
    771

    Re: structures as parameter

    nd is not a type, it is a variable. You sould change it to
    void insert_list(node **head, int num)
    The same problem occurs on the next two lines.

    Or maybe the nd should be a typedef?

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2004
    Location
    San Isidro
    Posts
    326

    Re: structures as parameter

    Quote Originally Posted by twanvl
    nd is not a type, it is a variable. You sould change it to
    void insert_list(node **head, int num)
    The same problem occurs on the next two lines.

    Or maybe the nd should be a typedef?
    thanks i got it
    I want to learn more
    grace

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width