Hi!
Code:
void test (int cod)
{
fstream fa, fb;
sSeg s;
sCon c;
long pos, pos1;
pos = search(cod); //returns position of cod in teste1.bin file
pos1= search_1(cod) //returns position of cod in teste2.bin file
fa.open("test1.bin",ios::in|ios::out|ios::binary);
if(!fa) {cerr<<"...";}
fb.open("test2.bin",ios::in|ios::out|ios::binary);
if(!fb) {cerr<<"..";}
fa.seekg(pos);
fa.read((char *)&s, sizeof s);
fa.seekp(pos);
s.cod_seg = (-1);
fa.write((char *)&s, sizeof s);
fb.seekg(pos1);
while(fb.read((char *)&c, sizeof c))
{
if(c.cod_seg == cod)
{
c.cod_ap = (-1);
fb.write ((char *)&c, sizeof c);
}
}
fa.close();
fb.close();
}
Why can't i write the modifications( c.cod_ap=1) in the test2.bin file?
The function apparently works but when i list the test2.bin file the changes do not appear.
Any ideas?
Thanks