I completely understand what a stack is supposed to do (last in, first out). It's just one part of the stack that gets me confused.
typedef struct dynArrStruct
{
char *location; //element
int length; //max size
int currSize; //top
}dynArr;
dynArr a; //declared in main
//sorry this is an assignment and I try to refrain from posting my full code
//on here b/c of potential cheaters
I use this code as my stack.
Basically my program is supposed to find balanced characters: '{', '(','<', '[' and their closing counter parts.
In a nutshell, everytime I find an opening brace, I push it onto the stack. I keep pushing it onto the stack until I find a closing brace and as soon as I find a closing brace I need to pop the stack.
What I'm getting confused is with the variable char* location.
Let's say my string is "()"
In GDB:
If I read in '(' I push it onto the stack.. and if I read in ')' I pop it.
When I do: p a->location it prints out "()"
I'm just wondering am I supposed to be deleting "()" from the value of a->location everytime I pop a stack or is popping the stack irrelevant to a->location?
In other words should it print out "" after it has been popped?
I apologize ahead of time if this question doesn't make sense