Skip to content

Instantly share code, notes, and snippets.

@mortymacs
Created August 25, 2024 08:04
Show Gist options
  • Save mortymacs/d2e05edac46b3bf4d15d8a61adf37a50 to your computer and use it in GitHub Desktop.
Save mortymacs/d2e05edac46b3bf4d15d8a61adf37a50 to your computer and use it in GitHub Desktop.
Dictionary by Glib in C
//gcc dict.c `pkg-config --libs --cflags glib-2.0`
#include <glib.h>
#include <stdio.h>
int main()
{
GHashTable* hash = g_hash_table_new(g_str_hash, g_str_equal);
g_hash_table_insert(hash, "name", "Mort");
g_hash_table_insert(hash, "email", "hello@localhost");
printf("Welcome dear %s <%s>\n", g_hash_table_lookup(hash,"name"), g_hash_table_lookup(hash,"email"));
g_hash_table_destroy(hash);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment