Hello, I am working on an assignment where we take a stack program and make it so it accepts characters. Then I need to add a main function that asks the user to input a series of braces or parenthesis and indicate whether or not they're properly nested. My program I need to modify is as follows: I do know a lot of the basics such as printf, return 0; and whatever, but these stacks are really messing with me. Any ideas or help on the subject?
Code:
#include <stdbool.h>
#define STACK_SIZE 100
int contents[STACK_SIZE];
int top = 0;
void make_empty(void)
{
top = 0;
}
bool is_empty(void)
{
return top == 0;
}
bool is_full(void)
{
return top == STACK_SIZE;
}
void push(int i)
{
if (is_full())
stack_overflow();
else
contents[top++] = i;
}
int pop(void)
{
if (is_empty())
stack_underflow();
else
return contents[--top];
}