Create a stack and perform push and pop operations using link list

Push : Push saves value in stack.The values having same data type can be pushed into stack.The value which is pushed at the last is stored at the top most position.

Pop : Push removes value from stack.The top most value is removed first i.e. LIFO policy.After removing a value from stack,the next value becomes the peek value.

#include < stdio.h >
#include < conio.h > 
#include < alloc.h >
struct stack
{
	int data;
	struct stack *next;
};
struct stack *pop(struct stack *top);
struct stack *push(struct stack *top);
void main()
{
	struct stack *top;
	int reply,option,data;
	clrscr();
	//...init stack
	top = NULL;
	do
	{
		printf("\n 1. push");
		printf("\n 2. pop");
		printf("\n 3. exit");
		printf("\nSelect proper option : " );
		scanf("%d",&option);
		switch(option)
		{
			case 1 : //push
				top = push(top);
				break;
			case 2 : //pop
				top = pop(top);
			break;
			case 3 : exit(0);
		}//switch
	}while(1);
} // main
struct stack *push(struct stack *top)
{
	struct stack *c;
	// creeate new node
	c = (struct stack*)malloc(sizeof(struct stack));
	if( c == NULL)
	{
		printf("Insuff. mem");
		return(top);
	}
	printf("\nEnter data : ");
	scanf("%d",&c->data);
	c->next = NULL;
	if( top == NULL)
		top = c;
	else
	{
		c->next = top;
		top = c;
	}
	return(top);
} // push
struct stack *pop(struct stack *top)
{
	struct stack *c;
	if( top == NULL)
	{
		printf("Stack is empty");
		return(top);
	}
	printf("\npopped data : %d",top->data);
	c = top;
	top = top->next;
	free(c);
	return(top);
} // pop