-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogram-07.c
More file actions
31 lines (21 loc) · 761 Bytes
/
program-07.c
File metadata and controls
31 lines (21 loc) · 761 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/*
Write a hash table in C
Inspired by: https://github.com/jamesroutley/write-a-hash-table
*/
#include <stdio.h>
#include "hash_table.h"
int main(void) {
ht_hash_table* hash_table = ht_new();
ht_insert(hash_table, "Gilson", "Urbano");
ht_insert(hash_table, "Brazil", "Denmark");
ht_insert(hash_table, "Age", "26");
char* value = ht_search(hash_table, "Gilson");
printf("Gilson %s\n", value ? value : "Not found");
value = ht_search(hash_table, "Brazil");
printf("Brazil -> %s\n", value ? value : "Not found");
value = ht_search(hash_table, "Age");
printf("Age: %s\n", value ? value : "Not found");
value = ht_search(hash_table, "Address");
printf("Street: %s\n", value ? value : "Not found");
ht_del_hash_table(hash_table);
}