views:

85

answers:

4

I want to use a stack in C, anybody recommend a library?

For example for a hash table I used UThash.

Thanks!

A: 

If you can fudge it a bit and use C++, Qt is a really great library with a lot of basic data structures.

kidjan
If C++ is acceptable, then Qt is not necessary. Stacks are in the C++ standard library.
larsmans
found one from previous question, thanks!
code2b
Lars, I'd still use Qt for all of the other primitives it provides. I find the C++ Standard Libraries woefully inadequate, but maybe that's my own personal preference.
kidjan
+1  A: 

Here is a similar question:

http://stackoverflow.com/questions/668501/are-there-any-open-source-c-libraries-with-common-data-structures

And here is CCAN, C's equivalent to CPAN:

http://ccan.ozlabs.org/

Noah Watkins
A: 

found one from previous question GLib, thanks

code2b
A: 

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);
}
Vovanium