there are two files:

Code:
/************ stack.check.c   */
#include<stdio.h>
#include"tree_stack.c"

struct node
{
	int element;
	struct node* next;
};
main()
{
	int ch;
	ch='y';
	int opt;
	
	struct node* tmp;

	do {
	       printf("\n************** MENU **********\n");
        	printf("\n\t1.add node\n\t2.Delete node \n\t3.display Stack\n");
		scanf("%d",opt);
		switch(opt)
		{
			case 1: 
				if( (tmp=(struct node*)malloc(sizeof(struct node*) )) == NULL)
				{	printf("memory error!!");   break;}
				printf("\nEnter the node element:\t");
				scanf("%d",tmp->element);
				tmp->next=NULL;
			        tree_push(tmp);        	
				break;
			case 2:
				tree_pop();
				break;
			case 3:
				tree_display();
				break;
		}
	printf("\ndo you wish to continue? [y/n]\t");
	scanf("%c",ch);
        }while(ch=='y');
}


and then 

**************tree_stack.c **********8888

#include<stdlib.h>

extern struct node nd;
struct st
{
	struct node* nd;
	struct st* next; 
};
struct st* top=NULL;
//struct st* tmp;


void tree_push(struct node* tnode)
{
 	struct st* tmp; 
  	 if( (tmp=(struct st*)malloc(sizeof(struct node*)))== NULL )
		printf("stack overflow!!\n");
         else
     	{

     		tmp->nd=tnode;
		tmp->next=top;
		top=tmp;
		printf("\n node successfully pushed!!\n");      	
         }
}


 struct node* tree_pop()
{	
	struct st* curr;
	extern struct node* n; 
	if(top==NULL)		
	{	
		printf("\n stack UnderFlow!!\n");
        	return NULL;
	}
	curr=top;
	n=curr->nd;
	top=top->next;
	free(curr);
	printf("\n stack popped!!\n ");
        return n;
}

void tree_display()
{
	struct st* curr;
	if(top==NULL)
		printf("\nstack empty!!\n");
	else
	{
		curr=top;
		while(curr != NULL)
		{
			printf("\t%d\t",curr->nd->element);
		}
	}
}
and error i am getting is :
%gcc -g -o stack_check stack_check.c
In file included from stack_check.c:2:
tree_stack.c: In function `tree_display':
tree_stack.c:56: error: dereferencing pointer to incomplete type
%
now i hope i have given the complete prob of mine ..thanks for help

Last edited by shabbir; 5May2009 at 16:41.. Reason: Code blocks