Associative arrays in C

前端 未结 7 1317
感动是毒
感动是毒 2020-12-01 00:33

I am implementing a way to transfer a set of data to a programmable dongle. The dongle is based on a smart card technology and can execute an arbitrary code inside. The inpu

7条回答
  •  旧巷少年郎
    2020-12-01 01:28

    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");
    

提交回复
热议问题