retagged by
567 views
0 votes
0 votes

Can anyone  check this program?

I got some warning.

#include<stdio.h>
#include<stdlib.h>
void func(struct node *);
    struct node
{
     int data;
   struct node *next;
};
   int main()
{
    struct node *head=(struct node *)malloc(sizeof(struct node));
 struct node *temp=(struct node *)malloc(sizeof(struct node));
  struct node *first=(struct node *)malloc(sizeof(struct node));
   head->data=10;
   head->next=temp;
   temp->data=20;
   temp->next=first;
   first->data=30;
   first->next=NULL;
       func(head);
return 0;
}

void func(struct node *p)
{
   if(p)
{   
    printf("\n%d",p->data);
  func(p->next);
}
}

retagged by

1 Answer

0 votes
0 votes
do the global function prototyping  after the structure definition

Related questions

2 votes
2 votes
2 answers
1
5 votes
5 votes
2 answers
3
shekhar chauhan asked Jun 28, 2016
1,521 views
Can Someone explain either Tree or Stack method to trace out this recursion ?What is the output of this Program ?