I am writing a text file which has the number of records in it at the start and then each record is stored at a 400 boundary - or rather should be!
In the following snippet the number of records is being updated and recorded at the start of the file OK but the string I am writing should be at 400, 800, 1200 etc but this part is not working, when I inspect the file there is only the one string and it's position varies only a little.
I am sure it must be an incorrect setting but I have tried all the ios::beg etc but none seem to make a difference
Code:jcin>>numrecords; jcin.close (); cout<<endl<<endl<<endl<<"There are currently "<<numrecords<<" records in this file."; ofstream jcout; jcout.open(filename, ios::out); long int pos; pos=(numrecords+1)*400; jcout.seekp (pos); jcout<<"hello sailor";//will be replace by a record cout<<endl<<"position is ; "<<pos<<endl; jcout.seekp (0); jcout<<numrecords++;//this is updating correctly jcout.close ();