#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;
	}

}

Edited 5 Years Ago by Narue: Added code tags

If you don't supply an explicit return type for a function, the compiler assumes that you meant int. So your declaration is:

void add_end(struct node **q);

And your definition with the implicit int added is:

int add_end(struct node **q)
{

That's the mismatch. Place a void explicitly in the definition (a good trick is to copy/paste the declaration when creating a definition) and all will be well:

void add_end(struct node **q)
{
This question has already been answered. Start a new discussion instead.