Truth table: Difference between revisions

→‎{{header|C}}: Added two functions in order allow the application to use the field "top" only through the operations on the stack.
(→‎{{header|C}}: Added two functions in order allow the application to use the field "top" only through the operations on the stack.)
Line 210:
exit(1);
}
}
 
void make_empty(stack_of_bool *sp) {
sp->top = -1;
}
 
int elems_count(stack_of_bool *sp) {
return (sp->top) + 1;
}
 
Line 229 ⟶ 237:
stack_of_bool s;
stack_of_bool *sp = &s;
s.top = -1make_empty(sp);
for (i = 0; i < expr_len; ++i) {
e = expr[i];
Line 257 ⟶ 265:
}
}
if (s.topelems_count(sp) != 01) {
printf("\nStack should contain exactly one element.\n");
exit(1);
Anonymous user