I am creating a program in C and I have a problem in my position where I can find a word at random from a dictionary of previously chosen with another function.
Code:
int line_no;
int i, j;
char word [20];
char caline;
srand (time (NULL));
line_no = rand ()% (long_dic) / / Remember to make a function to find the number of words in the dictionary
fseek (dic, line_no * long_no, 0);
rewind (dic);
while (line_no> 0)
(
caline = fgetc (dic);
if (caline== '\ n')
line_no -;
)
fgets (word, 20, dic);
for (i = 0; i <long_no; i + +) / / fill the structure test
(
es.mot [i] = word [i];
)
es.cache [1] = 1;
for (j = 1 j <long_no j + +)
(
es.cache [j] = 0;
)
)
Bookmarks