-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsort_words.c
66 lines (61 loc) · 1.66 KB
/
sort_words.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
62
63
64
65
66
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* sort_words.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: qnguyen <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/02/23 08:11:09 by qnguyen #+# #+# */
/* Updated: 2022/02/24 03:54:27 by qnguyen ### ########.fr */
/* */
/* ************************************************************************** */
#include "wordle.h"
//compile this as main file to combine poss and words into one sorted file
void ft_swapstr(char *str, char *str2)
{
char c[6];
ft_strcpy(c, str);
ft_strcpy(str, str2);
ft_strcpy(str2, c);
}
int main(void)
{
int fd;
int i;
int i2;
char *s;
char w_list[12972][6];
fd = open("list_of_possibilities", O_RDONLY);
i = 0;
while (get_next_line(fd, &s))
{
ft_strcpy(w_list[i], s);
free(s);
i++;
}
fd = open("list_of_actual_words", O_RDONLY);
while (get_next_line(fd, &s))
{
ft_strcpy(w_list[i], s);
free(s);
i++;
}
i = 0;
while (i < 12971)
{
i2 = i + 1;
while (i2 < 12972)
{
if (ft_strcmp(w_list[i], w_list[i2]) > 0)
ft_swapstr(w_list[i], w_list[i2]);
i2++;
}
i++;
}
i = 0;
while (i < 12972)
{
printf("%s\n", w_list[i]);
i++;
}
}