-
Notifications
You must be signed in to change notification settings - Fork 5
/
example.c
40 lines (30 loc) · 646 Bytes
/
example.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
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "map.h"
void callback()
{
printf("Hello World !\n");
}
int main()
{
struct map* m;
char *strval;
int intval;
void (*funcval)();
char* dynval = malloc(7);
m = mapNew();
strcpy(dynval, "dynval");
mapAdd("key 1", "value", m);
mapDynAdd("key 2", dynval, m);
mapAdd("key 3", (int*) 21, m); // Casted to avoid warning
mapAdd("key 4", callback, m);
strval = mapGet("key 1", m);
intval = (long) mapGet("key 3", m); // Casted to avoid warning
funcval = mapGet("key 4", m);
printf("%s\n", strval);
printf("%d\n", intval);
funcval();
mapClose(m);
return 0;
}