diff options
Diffstat (limited to 'libhashtable/example.c')
-rw-r--r-- | libhashtable/example.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/libhashtable/example.c b/libhashtable/example.c new file mode 100644 index 0000000..614e440 --- /dev/null +++ b/libhashtable/example.c @@ -0,0 +1,24 @@ +#include <stdio.h> +#include "libhashtable.h" + +extern char **environ; + +int main(int argc,char *argv[]) { + struct hashtable ht; + int i; + char *name; + char *value; + inittable(&ht); + for(i=0;environ[i];i++) { + name=strdup(environ[i]); + if((value=strchr(name,'=') )){ + *value=0; + value++; + } + //printf("'%s' = '%s'\n",name,value); + ht_setkey(&ht,name,value); + free(name); + } + printf("PATH='%s'\n",ht_getvalue(&ht,"PATH")); + return 0; +} |