Question: Given a struct as follows: Struct myStack{ int *data; int size; }; typedef struct myStack Stack; Write a C program to implement the following functions:

Given a struct as follows:

Struct myStack{

int *data; int size;

}; typedef struct myStack Stack;

Write a C program to implement the following functions:

a. void Stack_Init(Stack *S, int size);

//creates a stack of this size. You need to allocate memory appropriately (you can use a dynamically allocated array if you wish).

b. int peek(Stack *S);

//returns the value of the element on top w/o removing it

c. void Stack_Push(Stack *S, int d);

//pushes some integer onto the stack

d. int Stack_Pop(Stack *S);

//returns the value of the element on top and removing it

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!