Associative arrays in C

Glib’s hash table. implements a map interface or (associative array).
And it’s most likely the most used hash table implementation for C.

GHashTable *table=g_hash_table_new(g_str_hash, g_str_equal);

/* put */
g_hash_table_insert(table,"SOME_KEY","SOME_VALUE");

/* get */
gchar *value = (gchar *) g_hash_table_lookup(table,"SOME_KEY");

Leave a Comment