You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.0 KiB
C

#include <stdio.h>
#include "lookup_list.h"
int main(){
// Creating a new list
LookupList *l = NULL;
// Adding stuff
LookupList_add(&l, "Key1", "Value 1");
LookupList_add(&l, "Key2", "Value 2");
LookupList_add(&l, "Key3", "Value 3");
LookupList_add(&l, "Key4", "Value 4");
LookupList_add(&l, "Key5", "Value 5");
LookupList_add(&l, "Key6", "Value 6");
// Printing list
LookupList_print(l);
// Removing stuff
LookupList_remove(&l, "Key1");
LookupList_remove(&l, "Key3");
LookupList_remove(&l, "Key6");
LookupList_print(l);
// Retrieving using key
printf("%s\n",LookupList_get(l, "Key2", ""));
// Replacing old value
printf("%s\n",LookupList_get(l, "Key5", ""));
LookupList_add(&l, "Key5", "Replaced Value 5");
printf("%s\n",LookupList_get(l, "Key5", ""));
// Storing list as a binary
LookupList_store(l, "created_binary");
// Loading list from binary
LookupList *l1 = NULL;
LookupList_load(&l1, "created_binary");
assert(l1 != NULL);
LookupList_print(l1);
return 0;
}