I want to use a stack in C, anybody recommend a library?
For example for a hash table I used UThash.
Thanks!
The C Programming language has many data structures like an array, stack, queue, linked list, tree, etc. A programmer selects an appropriate data structure and uses it according to their convenience.
The pop and return external functions are provided with the argument stack library. The pop external functions are described below according to the data type of the value that each pops from the argument stack. The return external functions are described in Return functions for C.
C is not an object-oriented language, and it doesn't have standard libraries for things like queues.
C can't have an "exact equivalent" of STL because C doesn't have templates or classes.
Stack implementation fits in single sheet of paper.
That's simplest stack example
int stack[1000];
int *sp;
#define push(sp, n) (*((sp)++) = (n))
#define pop(sp) (*--(sp))
...
{
sp = stack; /* initialize */
push(sp, 10);
x = pop(sp);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With