Skip to content
Snippets Groups Projects
Select Git revision
  • 9938437729e467f9ac9b809a08273cd42e674b50
  • master default protected
2 results

main.c

Blame
  • Forked from algorithmique / cours
    563 commits behind the upstream repository.
    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); */
        /* } */
    }