Codice PHP:

#include <stdio.h>
#include <stdlib.h>

#define MAXSIZE 50

struct elem

   
int d;
   
struct elemnext;
};

typedef struct elem elem;

typedef struct stack
{
   
int cnt;
   
elemtop;
}
stack;

void init(stack*);
void push(stack*,int); 
int pop(stack*);
int top(stack*);
int IsEmpty(stack*);
int IsFull(stack*);
void stampa(stack*);

void init(stackstk)
{
     
stk->cnt=0;
     
stk->top=NULL;
}

void push(stackstkint d)
{
     
elemtmp=malloc(sizeof(elem));
     
tmp->d=d;
     
tmp->next=stk->top;
     
stk->top=tmp;
     
stk->cnt++;
}

int pop(stackstk)
{
    
int dato=stk->top->d;
    
elem *tmp=stk->top;
    
stk->top=stk->top->next;
    
stk->cnt--;
    
free(tmp);
    return 
dato;
}

int top (stackstk)
{
    return 
stk->top->d;
}

int IsEmpty(stackstk)
{
    return (
stk->cnt==0);
}

int IsFull(stackstk)
{   
    return (
stk->cnt==MAXSIZE);
}

void stampa(stackstk)
{
  if(
stk->cnt==0) return;
  else
  {
    
int tmp=pop(stk);
    
printf("%d ",tmp);
    
stampa(stk);
  }    

questo è il mio stack.h