C seems unusual by today’s standards because there are no useful data structures defined. None. Not even strings — and if you think a C string is a data structure, well, we’ll have to disagree on what a “data structure” is.
If you like C, then think of it as a “blank slate”… your entire application is made of code written by you and libraries you choose to pull in, plus a few fairly primitive standard library functions, with maybe one or two exceptions like qsort
. People use C these days to implement things like Python, Ruby, Apache, or the Linux kernel. These are projects that use all of their own data structures anyway, and they wouldn’t be likely to use something like the STL.
Many C libraries implement generic hash tables. There are tradeoffs, and you can pick your favorite. Some of them are configurable using callbacks.
- Glib has a hash table object (documentation)
- Apache Portable Runtime has a hash table (documentation)
- Apple’s Core Foundation library has a hash table (documentation) Note: Yes you can insert any object as key or value.
- UTHash is a hash table library (documentation)
- Another hash table library (link)
With all of these libraries that do what you want, what’s the point of adding a hash table to the C standard?