Select Git revision
Forked from
algorithmique / cours
563 commits behind the upstream repository.

orestis.malaspin authored
main.c 1.22 KiB
#include "hm.h"
#include <stdio.h>
int main() {
hm h;
hm_init(&h, 5);
for (int i = 0; i < 7; ++i) {
char key[MAX_LEN], value[MAX_LEN];
printf("Enter key please:\n");
scanf("%s", key);
printf("Enter value please:\n");
scanf("%s", value);
hm_set(&h, key, value);
hm_print(h);
}
printf("DELETE VALUES!\n");
for (int i = 0; i < 2; ++i) {
char key[MAX_LEN];
printf("Enter key please:\n");
scanf("%s", key);
printf("Value: ");
char *value = hm_remove(&h, key);
if (value == NULL) {
printf("Key not found.\n");
} else {
printf("Value is %s.\n", value);
}
hm_print(h);
}
printf("SEARCH VALUES!\n");
for (int i = 0; i < 2; ++i) {
char key[MAX_LEN];
printf("Enter key please:\n");
scanf("%s", key);
printf("Value: ");
char *value = hm_get(h, key);
if (value == NULL) {
printf("Key not found.\n");
} else {
printf("Value is %s.\n", value);
}
}
hm_destroy(&h);
/* for (int i = 0; i < 6; ++i) { */
/* scanf("%s", key); */
/* scanf("%s", value); */
/* } */
}