From b73be2bf711c3947c2b9d8fcf129486f9a536ff0 Mon Sep 17 00:00:00 2001 From: Orestis <orestis.malaspinas@pm.me> Date: Fri, 21 Feb 2025 11:41:52 +0100 Subject: [PATCH] added code --- slides/exemples/table_list.c | 41 ++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 slides/exemples/table_list.c diff --git a/slides/exemples/table_list.c b/slides/exemples/table_list.c new file mode 100644 index 0000000..1700f5f --- /dev/null +++ b/slides/exemples/table_list.c @@ -0,0 +1,41 @@ +#include <stdio.h> + +struct key_t { + int k; +}; + +struct value_t { + int v; +}; + +struct key_value_t { + struct key_t key; + struct value_t value; +}; + +struct elem { + struct key_value_t kv; + struct elem *next; +}; + +struct table { + struct elem *head; +}; + +struct value_t *sequential(struct table tab, struct key_t key) { + struct elem *e = tab.head; + while (e != NULL) { + if (e->kv.key.k == key.k) { + return &(e->kv.value); + } + e = e->next; + } + return NULL; +} + +int main() { + int w = 5; + /*int *v = NULL;*/ + int *v = &w; + printf("%d\n", *v); +} -- GitLab