I’m new at C and a bit at this site.
We were asked to balance symbols using stacks in C. I have a function push and pop which adds and deletes the symbols to be balanced, respectively. Whenever the string contains a {, (, [ or < symbol it pushes the single char to the stack. Else, it pops it. If at the end of the whole process, the stack is empty, it means the string entered is balanced.
if(string[i] == '(' || string[i] == '{' || string[i] == '[' || string[i] == '<')
push(string[i], s);
else
pop(s);
However, when I view it, the terminal prints numbers instead of the pushed symbols. Here is my view function:
int i;
for(i = 0; i < (s->tos + 1); i++)
printf("%d ", s->arr[i]);
You want to tell printf to print a character not a decimal
ie.