I identified where the problem seems to be:
Code:
fi.clear();
fi.seekp(0);
fa.seekg(0);
fb.seekg(0);
fa.read((char *)&c, sizeof c);
fb.read((char *)&d, sizeof d);
while (!fa.eof() && !fb.eof())
{
if (c.cod_cobertura > d.cod_cobertura)
{
fi.write((char *)&c,sizeof c);
fa.read((char *)&c, sizeof c);
}
else
{
fi.write((char *)&d,sizeof d);
fb.read((char *)&d, sizeof d);
}
}
while (!fa.eof() )
{
fi.write((char *)&c,sizeof c);
fa.read((char *)&c, sizeof c);
}
while (!fb.eof() )
{
fi.write((char *)&d,sizeof d);
fb.read((char *)&d , sizeof d);
}
fa.close();
fb.close();
fi.close();
When i enter this part of the program ( the 3 while's) a second time, it doubles the number of existing entries on the fi stream.
It appends the new information instead of writing from the beggining...
What i'm i doing wrong??
Thanks