Question: Design and implement a stack class (i.e. struct with accompanying functions) in C language. The interface should allow storing any data type including complex structures
Design and implement a stack class (i.e. struct with accompanying functions) in C language. The interface should allow storing any data type including complex structures (strings, int, float, etc). You can use malloc and free functions.
Sample:
// create a stack of capacity 5 with char data type
struct stack *st = newStack(5,CHAR);
st.push('a');
st.push('b');
// create a stack of capacity 5 with INTEGER data type
struct stack *st2 = newStack(5,INTEGER);
st2.push(3);
st.push('5);
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
