Code:
#define SIZE 10
struct student
{
int id;
char surname[20];
};
struct stack
{
struct student array[SIZE];
int top;
};
from the above data structures i need to implement the following:-
1. void initialise(struct stack *s);
2. int full(struct stack *s);
3. struct student *pop(struct stack *s);
Please check if it below is correct:-
Code:
void initialise(struct stack *s)
{
s->top == -1;
}
int full(struct stack *s)
{
return(s->top == SIZE - 1);
}
/*im not confident if the function below is right*/
struct student *pop(struct stack *s)
{
if(empty(s))
{
fprintf(stderr, "Stack underflow\n");
exit(1);
}
return &s->array[(s->top)--];
}
Please advice. Thank you
-hermit-