int j=1;
fstream kd("Gydytojai.sed");
while (!kd.eof())      // Checking if the entry already exist;
 { if (gydmas[j].vardas==pgyd.vardas) {ShowMessage(L"Gydytojo id jau egzistuoja");
                                        pagalb=true;};      // if the entry exist, variable pagalb becomes true
 j++;};
kd.close();

Well, i'm checking if in the file Gydytojai.sed while it is not end of line checking if my input text, which i compared with the array of structure from file is the same, if it's then pagalb becomes true. And in this thing i get an error of project. File is not empty.

You are not reading anything from the file, you only open the file and then enter an infinite loop incrementing j on every round. You must read in some data in order to compare the value of vardas.

Furthermore, about while(!kd.eof()) , please take a look in here
http://www.daniweb.com/forums/post155265-18.html

And lastly, you initialize int j=1; , is that on purpose? If not, notice that you are not comparing gydmas[[B]0[/B]] at all. Array indexes start from 0, not from 1.

You are not reading anything from the file, you only open the file and then enter an infinite loop incrementing j on every round. You must read in some data in order to compare the value of vardas.

Furthermore, about while(!kd.eof()) , please take a look in here
http://www.daniweb.com/forums/post155265-18.html

And lastly, you initialize int j=1; , is that on purpose? If not, notice that you are not comparing gydmas[[B]0[/B]] at all. Array indexes start from 0, not from 1.

I know about index, and i written it from 1, not from 0 ;) Anyway thanks for link.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.