Ясно, спасибо ...
буду приобщаться значит ...
а пока может кто объяснить, откуда вылезло вот это при выполнении скомпилированного кода:
#include <stdio.h>
#include <stdlib.h>
#include <cstdlib>
#include <ctime>
#define DICT "dictionary.txt"
using namespace std;
class wd
{
public:
char w [25];
int l;
};
class word
{
public:
wd *eng;
wd *rus;
int le;
int lr;
};
void words_ini (FILE *dict, word words [], int N);
void Interview (word words [], int N);
bool EQ (char arr1[], char arr2[], int m);
int main()
{
srand(time(0)+1);
//printf ("Dictionary file is a %s\n", DICT);
FILE *dict = fopen (DICT, "r");
int N;
fscanf (dict, "%d", &N);
word words [N];
words_ini (dict, words, N);
Interview (words, N);
int i = 0;
while (i<N)
{
delete[] words[i].eng;
delete[] words[i].rus;
i++;
}
return 0;
}
void words_ini (FILE *dict, word words [], int N)
{
int i = 0; //счетчик всех слов (строк) в словаре
int l;
char temp[25];
//char t[25];
while (i < N)
{
l = ftell (dict);
fscanf (dict, "%c%c", &temp[0], &temp[0]);
if (EQ(temp, "[", 1))
{
l = ftell (dict);
int m = 0; //счетчик слов
int ll=ftell (dict);
while (EQ (temp, "]", 1) != 1)
{
fseek (dict, ll, SEEK_SET);
fscanf (dict, "%s", &temp[0]);
m++;
ll=ftell (dict);
fscanf (dict, "%c%c", &temp[0], &temp[0]);
}
words[i].eng = new wd[m];
words[i].le = m;
fseek (dict, l, SEEK_SET);
m = 0; //теперь счетчик записанных в массив слов
while (m < words[i].le)
{
fscanf (dict, "%s", &words[i].eng[m].w);
ll = ftell (dict);
words[i].eng[m].l = ll - l - 1;
l = ll;
m++;
}
fscanf (dict, "%c%c", &temp[0], &temp[0]);
}
else
{
fseek (dict, l, SEEK_SET);
words[i].eng = new wd;
words[i].le = 1;
fscanf (dict, "%s", &words[i].eng[0].w);
words[i].eng[0].l = ftell (dict) - l - 1;
}
l = ftell (dict);
fscanf (dict, "%c%c", &temp[0], &temp[0]);
if (EQ(temp, "[", 1))
{
l = ftell (dict);
int m = 0; //счетчик слов
int ll=ftell (dict);
while (EQ (temp, "]", 1) != 1)
{
fseek (dict, ll, SEEK_SET);
fscanf (dict, "%s", &temp[0]);
m++;
ll=ftell (dict);
fscanf (dict, "%c%c", &temp[0], &temp[0]);
}
words[i].rus = new wd[m];
words[i].lr = m;
fseek (dict, l, SEEK_SET);
m = 0; //теперь счетчик записанных в массив слов
while (m < words[i].lr)
{
fscanf (dict, "%s", &words[i].rus[m].w);
ll = ftell (dict);
words[i].rus[m].l = ll - l - 1;
l = ll;
m++;
}
fscanf (dict, "%c%c", &temp[0], &temp[0]);
}
else
{
fseek (dict, l, SEEK_SET);
words[i].rus = new wd;
words[i].lr = 1;
fscanf (dict, "%s", &words[i].rus[0].w);
words[i].rus[0].l = ftell (dict) - l - 1;
}
i++;
}
}
void Interview(word words [], int N)
{
int i = 0;
int check;
int check_;
int t = 1;
char temp [25];
printf ("Check started\n");
while (t)
{
while (i < 10)
{
check = rand()%N;
check_ = rand()%words[check].lr;
printf ("%s - ", words[check].rus[check_].w);
scanf ("%s", &temp);
int ii = 0;
int tt = 0;
while (ii < words[i].le && tt == 0)
{
if (EQ (words[check].eng[ii].w, temp, words[check].eng[ii].l) == 1)
{
printf ("YES\n");
tt = 1;
}
}
if (tt == 0) printf ("NO, %s\n", words[check].eng[0].w);
i++;
}
printf ("\nDo you want to check your knowledge? [y/n]\n");
scanf ("%c", &temp[0]);
if (EQ("y", temp,1)) i = 0;
else t = 0;
}
}
bool EQ (char arr1[], char arr2[], int m)
{
int i = 0;
bool k=1;
while (i < m)
{
if (arr1[i] != arr2[i]) {k = 0; break;}
i++;
}
return k;
}