#include"stdio.h"
#include"conio.h"
#include"alloc.h"
struct node
{
int age;
char name[25];
struct node * next;
};
void add_end(struct node **q);
void display(struct node *);
void main()
{
struct node *p;
p=NULL;
add_end(&p);
//display(p);
getch();
return;
}
add_end(struct node **q)
{
struct node *temp,*r;
temp=*q;
if(*q==NULL)
{
temp=(struct node *)malloc(sizeof(struct node));
printf("\nEnter name\n");
gets(temp->name);
printf("\nEnter age\n");
scanf("%d",&temp->age);
temp->next=NULL;
*q=temp;
}
else
{
temp=*q;
while(temp->next!=NULL)
temp=temp->next;
r=(struct node *)malloc(sizeof(struct node));
printf("\nEnter name\n");
gets(r->name);
printf("\nEnter age\n");
scanf("%d",&r->age);
r->next=NULL;
temp->next=r;
}
}
Dhanesh10 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.