-
Notifications
You must be signed in to change notification settings - Fork 0
/
dictionary.c
39 lines (35 loc) · 955 Bytes
/
dictionary.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
#include <stdio.h>
#include <string.h>
#include "headers/dictionary.h"
#include "headers/utils.h"
#define MAXCHAR 200
#define MAXDICTSIZE 30000
int parseDictionary(char* filename) {
FILE *fp;
char str[MAXCHAR];
char*** dictionary;
char* initial_list[MAXDICTSIZE];
fp = fopen(filename, "r");
if (fp == NULL){
printf("Could not open file %s",filename);
return -1;
}
int i = 0;
int max_word_length = 0;
while (fgets(str, MAXCHAR, fp) != NULL && i < MAXDICTSIZE) {
initial_list[i] = allocate_string(str);
int length = strlen(initial_list[i]);
if (length > max_word_length) {
max_word_length = length;
}
i ++;
}
if (i == MAXDICTSIZE && fgets(str, MAXCHAR, fp) != NULL) {
printf("WARNING: Reached the maximum dictionary size, stopped reading before the end.");
}
fclose(fp);
int word_count_per_size[max_word_length + 1];
for (i = 0; i < max_word_length; i++) {
}
return 0;
}