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

}

Recommended Answers

All 3 Replies

hello friends, can anybody help me out here??

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)
{

thanks buddy!! :-)
just now i also found it out..
but thanks :-)

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.