-
Notifications
You must be signed in to change notification settings - Fork 90
/
Copy pathdict_use.c
41 lines (37 loc) · 1.19 KB
/
dict_use.c
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
32
33
34
35
36
37
38
39
40
41
/* Compile with:
mkdir -p hash
cp dict_use.c dict.h dict.c keyval.c keyval.h dict_test.c hash
cp dict.automake hash/Makefile.am
cd hash
touch NEWS README AUTHORS ChangeLog #still cheating
autoscan
sed -e 's/FULL-PACKAGE-NAME/hashdict/' \
-e 's/VERSION/1/' \
-e 's|BUG-REPORT-ADDRESS|/dev/null|' \
-e '12i\
AM_INIT_AUTOMAKE' \
-e '13i\
LT_INIT' \
-e '14i\
AC_CHECK_LIB([glib-2.0],[g_free])' \
-e 's|PROG_CC|PROG_CC_C99|' \
< configure.scan > configure.ac
autoreconf -i > /dev/null
./configure
make distcheck
make
*/
#include <stdio.h>
#include "dict.h"
int main(){
int zero = 0;
float one = 1.0;
char two[] = "two";
dictionary *d = dictionary_new();
dictionary_add(d, "an int", &zero);
dictionary_add(d, "a float", &one);
dictionary_add(d, "a string", &two);
printf("The integer I recorded was: %i\n", *(int*)dictionary_find(d, "an int"));
printf("The string was: %s\n", (char*)dictionary_find(d, "a string"));
dictionary_free(d);
}