c++ - Trouble with seekp() to replace portion of file in binary mode -


I'm having trouble with the place of one part of a file in binary mode. For some reason my looking () line is not giving the file indicator in the desired position to replace the desired portion just to attach the new content at the end of the file.

  long int pos; Bull got = wrong; Fstream file (filename, iOS :: binary | iOS :: out | iOS :: in); File.read (reinterpret_cast & lt; char * & gt; (and record), size (person)); While (! File.eof ()) {if (record.getNumber () == number) {pos = file.tellg (); Found = true; break; } // Record object has been updated here. File.seekp (pos, ios :: beg); // It does not keep the file pointer on the desired location file. Type (reinterpret_cast & lt; const char * & gt; (and record), size (person)); Cout & lt; & Lt; "Record updated." & Lt; & Lt; Endl; File.close ();  

Am I doing something wrong?

Thank you very much earlier.

I do not think how your loop can work (). Generally, you should not check for AOF () but instead check that if a reading job is done.

The following code writes a record in a file (which must be present) and then overwrites it:

  #include  

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -