This function creates 20 lines in this format:
then I attempt to overwrite one of the lines with a new record and this is what I get:Code:-2 000000000 * * -1 -2 000000000 * * -1
Now that file is meant to be parsed. the first number tells me whether it can be deleted, follow SSN, name, etc and the last number is a the byte offset in the file of then next relevant record. All records are supposed to take 50 bytes exactly but when I overwrite one, everything goes to hell.Code:-2 000000000 * * -1 -2 000000000 * * -1 -2 000000000 * * -1 -2 000000000 * * -1 0 111222333 alfonsines Delarumurationvuzure 50000 000000000 * * -1 -2 000000000 * * -1
I'm clearly doing something very wrong. Any help would be most appreciated.
Thanks.
Code:int i=0; int j = 0; fstream hashstream; long int Pointer (-1); ofstream hashwrite; hashwrite.open("hashprimary.txt"); for (j=0; j<=20; j++)//writes the 20 lines0 { hashwrite<<-2<<' '<<"000000000"<<' '<<"*"; for(i=0; i<10; i++) hashwrite<<' '; hashwrite<<"*"; for(i=0; i<20; i++) hashwrite<<' '; hashwrite<<Pointer<<' '<<"\n"; } hashwrite.close(); hashstream.open("hashprimary.txt", std::ios::in | std::ios::out);//Writes one line at offset 200 bytes hashstream.seekp(200, ios::beg); hashstream<<0<<' '<<"111222333"<<' '<<"alfonsines"; for(i=10; i<=10; i++) hashstream<<' '; hashstream<<"Delarumurationvuzure"; for(i=20; i<=20; i++) hashstream<<' '; Pointer = 50000; hashstream<<Pointer<<' '<<endl; hashstream.close();



LinkBack URL
About LinkBacks



