-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathundisp.c
61 lines (53 loc) · 1.06 KB
/
undisp.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "hash.h"
#include "disp.h"
char *c;
void init() {
;
}
void end() {
;
}
void getkeyval(char *key, char *val) {
printf("Enter key: ");
fgets(key, 1024, stdin);
c = strchr(key, '\n');
*c = '\0';
printf("Enter value: ");
fgets(val, 1024, stdin);
c = strchr(val, '\n');
*c = '\0';
}
void getkey(char *key) {
printf("Enter key: ");
fgets(key, 1024, stdin);
c = strchr(key, '\n');
*c = '\0';
}
void display(Table *t) {
unsigned int s = t->size;
while(s--) {
if(!t->e[s]) {
printf("%d: empty\n", s);
} else if(!t->e[s]->key) {
printf("%d: dummy\n", s);
} else {
printf("%d: %s, %s\n", s, t->e[s]->key, t->e[s]->val);
}
}
printf("\n");
}
void dispval(char *val) {
printf("Value: %s\n", val);
}
char in() {
char *str = calloc(3, sizeof(char));
char c;
printf("(i)nsert, (d)elete, or (g)et? ");
fgets(str, 3, stdin);
c = *str;
free(str);
return c;
}