plz tell why is the reason of this error :

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • 123 s
    New Member
    • Dec 2011
    • 1

    #1

    plz tell why is the reason of this error :

    #include<stdio. h>
    #include<ctype. h>

    typedef struct node
    {
    int value;
    struct node *next;
    struct node *prev;
    }mynode ;
    void add_node(struct node **head , int value);
    void print_list(char *listName , struct node *head );
    void getTheMiddle(my node *head);


    // The main function..
    int main()
    {
    mynode *head ;
    head = (struct node *)NULL;
    add_node(&head, 1);
    add_node(&head, 10);
    add_node(&head, 9);
    add_node(&head,-99);
    add_node(&head, 0);
    add_node(&head, 5);
    add_node(&head, 19);

    print_list(" myList " , head);
    getTheMiddle(he ad);
    return 0 ;
    }

    //This function uses one slow and one fast
    // pointer to get to the middle of the LL.
    // The slow pointer is advanced only by one node
    // and the fast pointer is advanced by two nodes!
    void getTheMiddle(my node *head)
    {
    mynode *p = head;
    mynode *q = head;
    if(q!=NULL)
    {
    while((q->next)!=NULL && (q->next->next)!=NULL)
    {
    p=(p!=(mynode *)NULL?p->next:(mynode *)NULL);
    q=(q!=(mynode *)NULL?q->next:(mynode *)NULL);
    q=(q!=(mynode *)NULL?q->next:(mynode *)NULL);
    }
    printf("The middle element is [%d]",p->value);
    }
    }
    // Function to add a node
    void add_node(struct node **head, int value)
    {
    mynode *temp, *cur;
    temp = (mynode *)malloc(sizeof (mynode));
    temp->next=NULL;
    temp->prev=NULL;
    if(*head == NULL)
    {
    *head=temp;
    temp->value=value;
    }
    else
    {
    for(cur=*head;c ur->next!=NULL;cur =cur->next);
    cur->next=temp;
    temp->prev=cur;
    temp->value=value;
    }
    }
    // Function to print the linked list...
    void print_list(char *listName, struct node *head)
    {
    mynode *temp;
    printf("\n[%s] -> ", listName);
    for(temp=head;t emp!=NULL;temp= temp->next)
    {
    printf("[%d]->",temp->value);
    }
    printf("NULL\n" );
    }

    error: expected ‘)’ before ‘(’ token
    error: expected ‘)’ before ‘*’ token
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    Beats me. There's no error in the code you posted according to Visual Studio.NET 2008.

    Comment

    Working...