Arandığında çalışan bir source file bulmak zor, bunu gcc compiler ile
derlediğinizde olumlu sonuc veriyor. Kaynak...

-- 
Uğur ARPACI
#include<stdio.h>
struct node 
{
	int data;
	struct node *link;
};
void push(struct node **, int);
int pop(struct node **);
int del_stack(struct node **);
int pop_all(struct node **);

int main (void) 
{
	struct node *s =NULL; // Initialize the struct 
	int i,user;
	do 
	{	printf("enter a number for stack:\n");
		scanf("%d",&user);
		push(&s,user);
		if (user == -1) break;
		
	}
	while (user);
	
	while (s !=NULL)
	{
		i=pop(&s);
	printf("item popped: %d \n",i);
}
		
//	i=pop(&s);
//	printf("item popped: %d \n",i);
//	i=pop(&s);
//	printf("item popped: %d \n",i);
//	i=pop(&s);
//	printf("item popped: %d \n",i);
	
	//del_stack(&s);
	return(0);
}
void push (struct node **top, int item) 
{
	struct node *temp;
	temp=(struct node *) malloc(sizeof(struct node));
	if (temp==NULL)  // this checks if the memory full 
	printf("\n Stack is full.");
	temp -> data=item;
	temp -> link=*top;
	*top=temp;
}
			
int pop (struct node **top) 
{
	struct node *temp;
	int item;
	if(*top == NULL)
	{
		printf("\n stack is empty.");
		return(0);
	}
	temp=*top;
	item=temp->data;
	*top=(*top) -> link;
	free(temp);
	return item;
}
int del_stack(struct node **top) {
	struct node *temp;
	if(*top == NULL)
	return (0);
	while (*top != NULL)
	{
		temp=*top;
		*top=(*top)->link;
		free(temp);
	}
}
_______________________________________________
Linux-programlama mailing list
[email protected]
http://liste.linux.org.tr/mailman/listinfo/linux-programlama

Cevap